I am not finding the use of
name
parameter of 'colModel' because i only want to display selected parameters from the 'cell' of the json. I am doing some sort of testing on flexigrid with json before implementing on my new project .
My script goes like this :
$(document).ready(new function(){
$("#fgrdProduct").flexigrid
(
{
url: 'registration/handlers/LoadUsers1.ashx',
dataType: 'json',
colModel : [
{ display: 'tameliTypeID', name: 'TameliTypeID', width: 20, sortable: true, align: 'left' },
{ display: 'tameliTypeName', name: 'TameliTypeName', width: 180, sortable: true, align: 'left' }
],
searchitems : [
{ display: 'TameliTypeID', name: 'TameliTypeID' },
{ display: 'TameliTypeName', name: 'TameliTypeName' }
],
sortname: "TameliTypeName",
sortorder: "asc",
usepager: true,
title: 'Tameli List',
useRp: true,
rp: 10,
showTableToggleBtn: true,
width: 805,
onSubmit: addFormData,
height: 200
}
);
My code returns the json in the format :
{"page":1,"total":9,"rows":[{"id":"0","cell":["{}","","Y","","","1","बिद्युतीय"]},{"id":"1","cell":["{}","","Y","","","2","अदालतको तामेलदारद्वारा"]},{"id":"2","cell":["{}","","Y","","","3","अन्य अदालतको माध्यमद्वारा"]},{"id":"3","cell":["{}","","Y","","","4","प्रहरीद्वारा"]},{"id":"4","cell":["{}","","Y","","","5","पत्रपत्रिका"]},{"id":"5","cell":["{}","","Y","","","6","हुलाक"]},{"id":"6","cell":["{}","","Y","","","7","स्थानीय निकाय"]},{"id":"7","cell":["{}","","Y","","","8","सरकारी अड्डा"]},{"id":"8","cell":["{}","","Y","","","9","म्यादवाला स्वयंम निबेदनबाट"]}]}
I also went through file
flexigrid.js
file and saw some code written for JSON case :
if (p.dataType == 'json') {
$.each
(
data.rows,
function (i, row) {
var tr = document.createElement('tr');
if (i % 2 && p.striped) tr.className = 'erow';
if (row.id) tr.id = 'row' + row.id;
$('thead tr:first th', g.hDiv).each
(
function () {
var td = document.createElement('td');
var idx = $(this).attr('abbr');
td.align = this.align;
td.innerHTML = row.cell[idx];
$(tr).append(td);
td = null;
}
);
Thanks in advance