0

I am new to jqGrid and Stack Overflow as well.. Well, I have a problem regarding the jqGrid SearchBox. Why does it show the search box in disabled mode?

Here is my code.

jQuery(document).ready(function(){
   var jsonData = '{"StartDate":"01/01/2009", "EndDate":"12/12/2010", "DateFormat":"dd/MM/yyyy", "BatchId":"21"}';
    jQuery("#attendance-grid").jqGrid({
        datatype: "json",
        mtype: "POST",
        url: "url/function",
        postData: jsonData,
        ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
        search: true,
        multipleSearch : true,
        jsonReader: {
            root: function (obj) { return obj.d.rows; },
            page: function (obj) { return obj.d.page; },
            total: function (obj) { return obj.d.total; },
            records: function (obj) { return obj.d.records; }
        },
        height: 'auto',
        rowNum: 10,
        rowList: [10,20,30],
        colNames:['Date', 'Batch', 'Enroolment No.', 'FName', 'MName', 'LName', 'Branch'],
        colModel:[
            {name:'date',index:'date', width:90, sorttype:"date", datefmt: 'm/d/Y', formatter:"date"},
            {name:'batch_name',index:'batch_name', width:150, sortable:true},
            {name:'Stud_EnrollNo',index:'Stud_EnrollNo', width:100, sortable:true},
            {name:'stud_fname',index:'stud_fname', width:80, sortable:true},
            {name:'stud_mname',index:'stud_mname', width:80, sortable:true},
            {name:'stud_lname',index:'stud_lname', width:80, sortable:true},
            {name:'currbranch',index:'currbranch', width:50, sortable:false}
        ],
        pager: "#pattendance-grid",
        loadtext: 'Loading...',
        sortname: 'stud_fname',
        viewrecords: true,
        gridview: true,
        rownumbers: true,
        sortorder: 'desc',
        grouping:true,
        groupingView : {
            groupField : ['stud_fname'],
            groupColumnShow : [true],
            groupText : ['<b>{0} - {1} Item(s)</b>'],
            groupCollapse : true,
            groupOrder: ['desc']
        },
        caption: "Attendance Report"
    }).navGrid('#pattendance-grid',
        { search:true,
            view: true,
            del: false,
            add: false,
            edit: false,
            searchtext:"Search" },
        {}, // default settings for edit
        {}, // default settings for add
        {}, // delete
        {closeOnEscape: true, multipleSearch: true,
              closeAfterSearch: true }, // search options
        {}
    );
Justin Ethier
  • 131,333
  • 52
  • 229
  • 284
ANKIT
  • 431
  • 1
  • 10
  • 22

1 Answers1

0

Probably your main problem is that you use postData parameter in the wrong way. If you use is as a string, then the postData overwrite all other typical jqGrid parameters. Try to change postData parameter as

postData: {
    StartDate:"01/01/2009",
    EndDate:"12/12/2010",
    DateFormat:"dd/MM/yyyy",
    BatchId:21
}

Moreover you should not use multipleSearch:true as jqGrid parameter: only inside of parameters of navGrid function it has any sense.

What you additionally could needed is

serializeRowData: function (data) {return JSON.stringify(data);}

where JSON.stringify is a part of json2.js from here

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • oh thx for fast response thnq vry mch, i'l chk nd cm back to u sooon 1's again THNX.. – ANKIT Feb 13 '11 at 11:34
  • hi Oleg i;m still there (with problem), i dont know why & where the problem is.. 1 more thing as u hv give suggestion of postdata, grid not working in that case.. as i noticed StartDate, EndDate not a predefined parameters so that could b an issue... plzzzzzzz do something.. – ANKIT Feb 13 '11 at 14:51
  • @Ankit: I don't understand why you want to send such `jsonData` if the server not read the data. I suppose you use ASMX web services on the server side. You should post the code of the server part. Look http://stackoverflow.com/questions/3169408/jqgrid-setgridparam-datatypelocal/3170652#3170652 or download the working example http://www.ok-soft-gmbh.com/jqGrid/WebServicesPostToJqGrid.zip – Oleg Feb 13 '11 at 19:04
  • hiii Oleg i'v posted 1 more snippet plz have a look and help me.. here is the link http://stackoverflow.com/questions/4994424/jqgrid-search-box-is-disabled-2 – ANKIT Feb 14 '11 at 16:20