Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :
Java
$(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 :

Java
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;

         //add cell
         $('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
Posted
Updated 19-Mar-12 0:20am
v2
Comments
Slacker007 19-Mar-12 6:21am    
Edits: Formatted code blocks and some readability. Shortened question title.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900