EasyUI Forum
March 29, 2024, 04:28:22 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Json content contain json,how can display in datagrid?  (Read 4758 times)
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« 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" }  ]  }"
« Last Edit: November 23, 2017, 11:46:44 PM by frankgao » Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #1 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
};
}
})
Logged
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« Reply #2 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.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2260


View Profile Email
« Reply #3 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.
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!