Hi There,
Please pardon me if I’ve posted in wrong forum. (help forum)
I’m working on dynamic column for jqGrid.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$.ajax({ mtype:'GET', dataType: "json", //dataType T has to be in UPPER case url:'illumina/xhr_manage_samples_pipeline', success: function(data){ column_name=data.column; //get column names model=data.model; //holds model for column sample_details=data.sample_details; //row datum //json reader $("#grid_illumina_manage_samples2").jqGrid({ jsonReader: { repeatitems: false, id: "", }//json_reader ends colNames: column_name, colModel: model, data: sample_details, pager: '#pager_illumina_manage_samples2', gridview: true, });//grid ends }//successs ends });//ajax ends |
My data looks (json_encoded):
|
1 2 3 4 5 6 |
{"column": ["Sample group Name","Sample list"], "model":[{"name":"sample_group_name"},{"name":"sample_name"}], "sample_details":[{"sample_group_name":"dell_man","sample_name":"A101,A11,B100","sample_count":3}, {"sample_group_name":"asdsad","sample_name":"10,210","sample_count":2}]} |
On PHP side, my associative array looks like:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$data=array(); //creat an empty array $data['column'][]= 'Sample group Name'; $data['model'][]['name']="sample_group_name"; $data['column'][]= 'Sample list'; $data['model'][]['name']="sample_name"; //query to add sample_group, and list.. push them in $data echo json_encode($data); //dataType is important on the json GET ajax |
In console.log – I get exact data, column model, column names, however data is not loaded in my grid.
The reason I’m going for this approach is I’ve dynamic columns.
Here for the sake of example, and showing issue facing, I’ve restricted to the ones which will be there by default, for which row data has to be loaded.
Any help shall be highly appreciated,
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top