How to perform toolbar searching based on certain condition in free jqgrid 4.15.4

203 views Asked by At

Though I have spent a lot of time on looking for similar QA here but Can't able to find out. If You think that I missed checking something please let me know.

question metadata:
So I am using free jqGrid 4.15.4 for showing data in view. I am able to do all things with awesome documentation. but one certain condition where I am not getting about steps.

In my grid, I have 4 columns named as Id, Name, Group, and Status. Group(Section A/ Section B....) are coming from database. Status(New/Pass /Fail) column consist dropdown and by default value is "New" for all records.

question statement :

There are 5 records and I have Selected "Pass" status for 2 out of 5. Now I want to see all 5 records if I select "New" in filter toolbar for that particular group(section A). Since I don't how many names belongs to that particular group, so I want to check this by filtering all records with "New" status. Is this possible with jqgrid? StudentGrid.png

Here is the code snippet:

$("#grid").jqGrid({
    url: '/StudentsView/GetAllData',
    mtype: "GET",
    datatype: "json",
    colNames: ['Id','Name', 'Group','Status'],
    colModel: [
                {label: "Id",name: 'Id',hidden: true,search: false,key:true},
                {label: "Name",name: 'Name', search: true, stype: 'text'},
                {label: "GroupNo",name: 'GroupNo',searchoptions: {searchOperators: true,sopt: ['eq', 'cn', 'nc'] }, search: true, multipleSearch: true, multipleGroup:true},
                {
                    label: "Status",
                    name: 'Status',
                    cellEdit: true,
                    edittype: 'select',
                    editable: true,
                    editoptions: {
                    value: getStatusOptions(),
                    dataEvents: [{
                        type: 'change',
                        fn: function (e) {
                        if (statusid != 0) 
                            {
                                ChangeStatus(row.Id, row.Name, row.Group, statusid);                       
                            }
                        }
                    }],
                    }
                }
    pager: jQuery('#pager'),
    loadonce: true,
    viewrecords: true,
    gridview: true,
    iconSet: "fontAwesome",
    emptyrecords: "No records to display",
    jsonReader:
    {
        root: "rows",
        page: "page",
        total: "total",
        records: "records",
        repeatitems: false,
        Id: "Id"
    }
});
$('#grid').jqGrid('filterToolbar', { stringResult: true,searchOnEnter:false, defaultSearch: "cn", multipleSearch: true, searchOperators: true, 
search: true, loadFilterDefaults: true });
$('#grid').jqGrid('navGrid', "#pager", {
    search: false, // show search button on the toolbar
    add: false,
    edit: false,
    del: false,
    refresh: true
});

I have added a diagram for better understanding. Thanks in Advance.

0

There are 0 answers