Front desk: Dhtmlxgrid. Displaying data
The format is:
{
rows:[
{id:1,data:[1,2,3]}
,{}
]
}
What if you generate such a string directly in the Postgesql?
That's what we're going to do today.
It was also tested one day, or someone else's help was done:
I write myself, how can not achieve this goal:
3, group friends to the solution: the Perfect solution
--Scenario 1:Select Json_agg (Row_to_json (t))::TextFrom (Select Id,concat_ws (‘,', pt_name,pt_description)As MyDataFrom Project_template)AsT--result [{"id": 1, "MyData": "Whq,admin"},{"id": 2, "MyData": "Eathon,sys"}]--Not ideal--Scenario 2:Select Json_agg (Row_to_json (t))::TextFrom (Select ID,‘[‘|| Concat_ws (‘,', pt_name,pt_description)||‘]‘As MyDataFrom Project_template)AsT--result [{"id": 1, "MyData": ["Whq,admin"]},{"id": 2, "MyData": ["Eathon,sys"]}] it seems right, but look closely: "MyData":["Eathon,sys"]No, it should be: "MyData":["Eathon", "SYS"]--Scenario 3:Select Json_agg (Row_to_json (t))::TextFrom (Select Id,array[pt_name,pt_descriptionas mydata from project_template where =1 and id= as t--result: [{"id": 1, " MyData ": [" WHQ "," admin "]},{" id ": 2, "MyData": [ "Eathon", "SYS" /span>
PostgreSQL directly generates a JSON string that Dhtmlxgrid can accept