JQuery EasyUI Treegrid cannot display json object data correctly using formatter -
i have jsondata follows:
"rows":[ {"code":"001","name":"name 1","addr":"address 11","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"002","name":"name 2","addr":"address 13","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"003","name":"name 3","addr":"address 87","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"004","name":"name 4","addr":"address 63","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"005","name":"name 5","addr":"address 45","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"006","name":"name 6","addr":"address 16","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"007","name":"name 7","addr":"address 27","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"008","name":"name 8","addr":"address 81","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"009","name":"name 9","addr":"address 69","col4":{"data":"col4 data","value":"col4 value"}}, {"code":"010","name":"name 10","addr":"address 78","col4":{"data":"col4 data","value":"col4 value"}} ]
intended display data , value of col4 in 2 different columns. hence added following in treegrid table definition.
{field:'col4',title:'col41 data',width:150,rowspan:2,formatter:function (value,row,index){return value["data"];}}, {field:'col4',title:'col41 value',width:150,rowspan:2,formatter:function (value,row,index){return value["value"];}}
expected work only data field visible formatter. second formatter never works column.
does know of workaround available?
you should change name of field ... jesasyui matches field name json sent , adds corresponnding value..so since field name same both columns appends respective object...
try this
{field:'col4_data',title:'col41 data',width:150,rowspan:2,formatter:function (value,row,index){return row.col4["data"];}}, {field:'col4_value',title:'col41 value',width:150,rowspan:2,formatter:function (value,row,index){return row.col4["value"];}}
Comments
Post a Comment