Linkage of checkbar and data field
You can use it by linking checkbars and data fields.
caution
- onItemChecked() occurs when the check bar is checked.
- Checking is possible with gridView.checkItem(), checkItems(), checkRow(), and checkRows(). (onItemChecked(), onItemsChecked() occurs, events related to grid editing do not occur)
- If you set the value of the field connected to the check bar with setValue(), it will be displayed in conjunction with the check bar according to the value. In this case, onItemChecked() does not occur.
If dataType: "boolean"
If dataType is boolean, you only need to connect checkBar and field. The 'Boolean' column is set for example purposes, and in actual use, only the field needs to be set. Check the change in the value displayed in the Boolean column when you check the check bar.
//Type of data
[
{
"Bool1": true,
"Bool2": "Y",
"KorName": "Park Young-ho",
"Gender": "Male",
... skip ...
},
{
"Bool1": false,
"Bool2": "N",
"KorName": "Jo Il-hyung",
"Gender": "Male",
... skip ...
}
... skip ...
]
//Field settings
var fields = [
{
fieldName: "Bool1",
dataType: "boolean"
},
... skip ...
]
dataProvider.setFields(fields);
//Option settings
gridView.checkBar.fieldName = "Bool1"; //Connect with Bool1 field
If dataType: "text"
If the dataType is text, just connect checkBar and field and specify (BooleanFormat) the text to be treated as True and the text to be treated as False. The 'text' column is set for example purposes, and in actual use, only the field needs to be set. Check the change in the value displayed in the Boolean column when you check the check bar.
//Type of data
[
{
"Bool1": true,
"Bool2": "Y",
"KorName": "Park Young-ho",
"Gender": "Male",
... skip ...
},
{
"Bool1": false,
"Bool2": "N",
"KorName": "Jo Il-hyung",
"Gender": "Male",
... skip ...
}
... skip ...
]
//Field settings
var fields = [
{
fieldName: "Bool2",
dataType: "text",
booleanFormat: "N:Y" //Text to be processed as false, text to be treated as true separated by ":"
},
... skip ...
]
dataProvider.setFields(fields);
//Option settings
gridView.checkBar.fieldName = "Bool2"; //Connect with Bool2 field
If there are multiple true and false values to be specified as BooleanFormat, set them separately with , as shown below.
var fields = [
{
fieldName: "Bool2",
dataType: "text",
booleanFormat: "N,n,0:Y,y,1" //Text to be processed as false, text to be treated as true separated by ":"
},
... skip ...
]