Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
jqGrid addJSONData works BUT when i filter data with filtertoolbar the grid goes blank
15/01/2013
16:06
Avatar
caraballopablo
New Member
Members
Forum Posts: 2
Member Since:
15/01/2013
sp_UserOfflineSmall Offline

Hello im using jqGrid 4.4.1

with datatype:"local".

first:

i have the grid filled with 2 records/rows when the grid init for the first time (Rows ID=10 and ID=20).

then: i call an ajax to fill the grid with more records (about 900 rows), im calling addJSONData method, the grid show the 900 rows BUT... when i filter by last name, name or any input (with filtertoolbar) and hit ENTER, the grid goes blank, then when i click to clean/reset/restore the filters, the grid fill up/charge ONLY the 2 first rows of the first time (Rows ID=10 and ID=20, the new 900 rows dont seem to charge).

Its seems that the grid is applying the filter internally ONLY with the 2 first values of the init time (Rows ID=10 and ID=20).

before using addJSONData i use jqGrid('addRowData') BUT with more volume of data the performance crash, thats why i must use addJSONData.

Thanks.

Code:

    var mydata = [        
            {
            id:"10",firstname:"SAMPLE1",lastname:"SAMPLE10"
            },
            {
            id:"20",firstname:"SAMPLE2",lastname:"SAMPLE20"
            }
        ];
        
        jQuery("#myGrid").jqGrid(
            {
                data: mydata,
                datatype: "local",
                colNames:['ID','First Name', 'Last Name'],
                colModel:[
                        {name:'id',index:'id', width:250, sortable:false, editable:false, sorttype:'text',search:true,searchoptions:{sopt:['cn','nc']},searchhidden:true},
                        {name:'firstname',index:'firstname', width:250, sortable:false, editable:false, sorttype:'text',search:true,searchoptions:{sopt:['cn','nc']},searchhidden:true},
                        {name:'lastname',index:'lastname', width:250, sortable:false, editable:false, sorttype:'text',search:true,searchoptions:{sopt:['cn','nc']},searchhidden:true}
                ],
                rowNum:1000,
                rowList:[10,20,30,50,100,1000],
                height: 350,
                width: 1000,
                rowTotal:500000,
                pager: '#pmyGrid',
                sortname: 'firstname',
                sortorder: "asc",
                viewrecords: true,
                caption:"Grid",
                //shrinkToFit:false,
                footerrow: true,
                userDataOnFooter: true,    
            }
        );
        jQuery("#myGrid").jqGrid('navGrid','#pmyGrid',{add:false,edit:false,del:false});
        jQuery("#myGrid").jqGrid('bindKeys');
        jQuery("#myGrid").jqGrid('filterToolbar', {
                   beforeSearch: function() {
                   }
                 }
        );

To fill up i use:

        eval("mydata="+partetxt+";");
        jQuery("#myGrid")[0].addJSONData(mydata); //Fill well but dont see in new filters.

16/01/2013
09:47
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

To fill up you should use the following code:

mydata = eval("mydata="+partetxt+";");

jQuery("#myGrid").jqGrid('setGridParam', {data : mydata}).trigger('reloadGrid');

You use data parameter initially and you must use this parameter to fill up again.

It is very important that you set the key property in colModel  (or use keyIndex) in order the grid to work fine.

See the docs for these properties

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

16/01/2013
18:10
Avatar
caraballopablo
New Member
Members
Forum Posts: 2
Member Since:
15/01/2013
sp_UserOfflineSmall Offline

Thank you!, it works well, a few tips to take note:

when i use datatype:"local" always i must use the same structure of local array with json within:

   var mydata = [        
            {
            id:"10",firstname:"SAMPLE1",lastname:"SAMPLE10"
            },
            {
            id:"20",firstname:"SAMPLE2",lastname:"SAMPLE20"
            }
        ];

and when i use datatype:"json" and url:"xxx" (not local) i must use another structure:

{

        "page":"1″,"total":1,"records":"928″,

        "rows":[

                   {"cell":["10","SAMPLE1","SAMPLE10"]},

                   {"cell":["20","SAMPLE2","SAMPLE20"]}

                   ]

}

its very important (like you said) the correct use of keyindex, because if you dont, it wont work well the new add.

example: if in my variable "mydata" i use firstname:"xxx", then i must use in colModel an index:"firstname"

Regards.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information