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
RowID parameter in addRowData does not function correctly
29/09/2010
09:25
Avatar
MaximG
Member
Members
Forum Posts: 10
Member Since:
27/09/2010
sp_UserOfflineSmall Offline

Code to recreate problem:

 $(function () {
            $("#tableSearch").jqGrid({
                datatype: "local",
                colNames: ['Type', 'Description', 'Options'],
                colModel: [{ name: 'Type', index: 'Type', width: 50, align: "center" },
                            { name: 'Description', index: 'Description', width: 230, sortable: true },
                            { name: 'Options', index: 'Options', width: 69, sortable: false}],
                rowNum: 10,
                sortname: 'type',
                sortorder: "desc",
                id: "RowID",
                caption: "Search",   
                rowList: [10, 20, 30],
                pager: "#divPager",
                gridComplete: function () {
                }
            })
        });

        function GoGoGo() {
            $("#tableSearch").clearGridData();
            $("#tableSearch").addRowData("RowID", [{ RowID: "101", Type: "Type", Description: "Desc", Options: "Option" }, { RowID: "102", Type: "Type", Description: "Desc", Options: "Option"}]);
            $("#tableSearch").trigger("reloadGrid");

            var test1 = $("#tableSearch").getDataIDs();
            debugger;    
            //Will return ID of 1 for row 1
        }

29/09/2010
10:33
Avatar
MaximG
Member
Members
Forum Posts: 10
Member Since:
27/09/2010
sp_UserOfflineSmall Offline

Ok so I worked out what was going on.

The problem is the $("#tableSearch").trigger("reloadGrid"); method. However this must be called
to enable paging to work with local data (It does work fine once this is called)

The problem with the method is it causes a call to the addJSONData method which in turn contains the following line

var dReader = ts.p.datatype == "local" ? ts.p.localReader : ts.p.jsonReader, locid, locdata = (ts.p.datatype != "local" && ts.p.loadonce) || ts.p.datatype == "jsonstring";

this is where the problem is. At this point whatever is set as your localreader id value is now
being used rather then the original rowID value, hence since your object (in my case)
doesnt contain the default value id a new rowid is generated and bammm your old values are
thrown out.

So basically the temp solution to this is to add the following to your original declaration

localReader: { id: "MyRowID"}

But really this is probably a value that should get overwritten in the addRowData method???

Either way its up to you guys to work out…

Hopefully this helps someone :-)

PS: Thanks again for writing this grid… It Rocks…

29/09/2010
11:20
Avatar
MaximG
Member
Members
Forum Posts: 10
Member Since:
27/09/2010
sp_UserOfflineSmall Offline

Turns out this problem gets even more interesting. Realized that after all that I had forgotten that during my

testing I added a column in the colModel as such

{ name: 'MyRowID', index: 'MyRowID', hidden: true }

If this column doesnt exist the entire process described above again breaks.

This seems to be a result of the fact that if the column – for the rowid – doesnt exist in the column model it is not

remembered by the grid and stored in the data collection therefore on the second pass (during the reloadGrid method)

it loses the value (again).

Hopefully this makes some sense to you guys

02/10/2010
20:10
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Please look here :

http://www.trirand.com/blog/?p.....ta/#p20116

Kind Regards

Tony

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
55 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