EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: frankgao on November 23, 2017, 11:42:47 PM



Title: Json content contain json,how can display in datagrid?
Post by: frankgao on November 23, 2017, 11:42:47 PM
One row json,here one column name is content,and this content is json.
so,it's can not display in datagrid?

Code:
{"total":1,"rows":[{"syssmsid":"5685","syssmssendid":"13603","title":"test","contents":"{  "sites": [  { "name":"facebook" , "url":"www.facebook.com" },   { "name":"google" , "url":"www.google.com" },   { "name":"google plus" , "url":"www.google.com" }  ]  }","builddate":"2017-11-23 17:18:59","emname_st":"Name","type":"2","builder":"1","flag":"False","rownumber":"1"}]}

Code:
"contents":"{  "sites": [  { "name":"facebook" , "url":"www.facebook.com" },   { "name":"google" , "url":"www.google.com" },   { "name":"google plus" , "url":"www.google.com" }  ]  }"


Title: Re: Json content contain json,how can display in datagrid?
Post by: jarry on November 24, 2017, 02:08:10 AM
Please define the 'loadFilter' function to convert the original data source.
Code:
$('#dg').datagrid({
loadFilter: function(data){
var sites = data.rows[0].contents.sites;
return {
total: sites.length,
rows: sites
};
}
})


Title: Re: Json content contain json,how can display in datagrid?
Post by: frankgao on December 21, 2017, 11:07:42 PM
Please define the 'loadFilter' function to convert the original data source.
Code:
$('#dg').datagrid({
loadFilter: function(data){
var sites = data.rows[0].contents.sites;
return {
total: sites.length,
rows: sites
};
}
})

Sorry,maybe I am not clear my question,the content is richtext,sometime this json or html.
So,I don't know how can display the field what ever the text content type.


Title: Re: Json content contain json,how can display in datagrid?
Post by: jarry on December 22, 2017, 05:24:29 PM
The 'loadFilter' method allows you to convert any other data to the standard json data that the datagrid requires. If you have different data source returned from your server, you should convert them separately according to your data format. Another way to solve your issue is to convert data format in your server before returning to the browser.