EasyUI Forum
June 30, 2024, 04:17:02 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to make a text field in datagrid 'required'?  (Read 17023 times)
tomhj
Newbie
*
Posts: 40


View Profile
« on: July 19, 2012, 10:25:52 PM »

I have a treegrid with editable columns with types 'combobox', 'text', and 'checkbox'.  The combobox and text fields are required.  I can specify through the editor for the combobox and the options property that the field is required: true.  But I don't see how to make the text field 'required'.  The 'options' property seems to be ignored for that editor type.

Am I missing something? 
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 19, 2012, 11:05:49 PM »

The 'text' editor is a simple textbox. To use additional editing options, please use the 'validatebox' editor:
Code:
columns:[[
{field:'name',title:'Name',width:120,
editor:{
type:'validatebox',
options:{
required:true
}
}
},
...
]]
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #2 on: July 19, 2012, 11:14:49 PM »

Thanks - that works.  One odd thing though:  when the row switches into edit mode, the combobox immediately shows the "this field is required" icon but the text/validatebox field doesn't show it until that field has the focus.  Is that normal/expected behavior?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 20, 2012, 01:29:04 AM »

When edit a row, all the empty field with 'required' property will display an alert icon on right of textbox. When move the mouse over the empty field with 'required' property, the 'this field is required' message will show immediately.
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #4 on: July 20, 2012, 08:23:46 AM »

That's what I was expecting, but it isn't what I'm seeing.  The newly inserted row shows the red triangle icon in the required combobox field but not the validatebox field.  The red triangle icon doesn't show in empty the validatebox field until I click in that edit box - then it stays there until I enter a value.

Here is the field definition for that column:

{field: 'name', title: 'Name', width:150, sortable:true, resizable:true, editor: { type: 'validatebox', options: {required: true}}}
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #5 on: July 20, 2012, 10:00:06 AM »

I figured out the problem - there was another column/field with a formatter that wasn't properly handling the field value being undefined.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!