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_TopicIcon
Bug with idPrefix (duplicate idPrefix)
18/01/2012
17:02
Avatar
Klaus
Member
Members
Forum Posts: 68
Member Since:
18/11/2009
sp_UserOfflineSmall Offline

Hello!

After updating jqGrid to the latest releases (jqGrid 4.3.1, jQuery 1.7.1) and using the new idPrefix option for my grids I detected the following problem:

In some cases the idPrefix is added/used twice for the table rows id attribute (... id="pre_pre_12"). This problem seems to occur when using a grid with local data added via addRowData ...

myTable.jqGrid("clearGridData");
myTable.jqGrid("addRowData", "id", myData);
myTable.jqGrid('sortGrid', 'name', true, 'asc');

jqGrid calls the following internal functions: addRowData and then addJSONData for each row ... I think this is the cause of the problem, why the prefix is added twice.

On the other hand, when using server side data (JSON) the ids are set correctly using the idPrefix only once. (... id="pre_12")

I've solved the problem by checking each time the prefix is appended, if it is already included in the ID and only add it if not.

But I don't think this is a really good solution. Maybe someone who knows the jqGrid code better could provide a clean bugfix for that problem.

Kind regards,
Klaus.

18/01/2012
18:31
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Do you have checked your myData?

Please veryfy that myData does not have any id with like pre_12 before it is added into the grid

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.

18/01/2012
19:07
Avatar
Klaus
Member
Members
Forum Posts: 68
Member Since:
18/11/2009
sp_UserOfflineSmall Offline

Hello,

I've verified the data, and it is totally correct, but then I've found the exact position, when the problem happens ... it is the sortGrid call and not the addRowData!

After the data was added with addRowData the ids where still correct, but after calling the sortGrid method the ids got wrong (with double-prefix)!

Here are some more details about my configuration:

tableSettings= {
  idPrefix: "pre_",
  datatype: "local",
  colModel: [
    {label: 'Name', name: 'name', index: 'name', jsonmap: 'name'},
    {label: 'ID',   name: 'id',   index: 'id',   jsonmap: 'id'}
  ]
  jsonReader: {
    root: "entries",
    page: "tablepage",
    total: "tablepagetotal",
    records: "tablerecords",
    repeatitems: false,
    id: "id"
  },
  ...
}

myData = [          /* it doesn't matter if the ids are strings or int ... same bahaviour */
 {id: "1", name: "test1"},
 {id: "2", name: "test2"}
];

myTable.jqGrid('addRowData', "id", myData);
myTable.jqGrid('sortGrid', 'name', true, 'asc');

Kind regards,
Klaus.

02/05/2012
06:59
Avatar
bigD
New Member
Members
Forum Posts: 1
Member Since:
02/05/2012
sp_UserOfflineSmall Offline

Hi

We are also seeing this issue, can you elaborate on your solution?  

Thanks

10/05/2012
15:12
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I hope that the problem is fixed.

Couild you please let us know which version is used.

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.

18/05/2012
08:11
Avatar
maxfelipe
Member
Members
Forum Posts: 3
Member Since:
18/05/2012
sp_UserOfflineSmall Offline

I have the latest version (4.3.2) (with no code from github) and I'm also seeing the issue when the grid is sorted. I don't think Klaus actually fixed the issue, he was just pointing where he things the issue happens.

Moreover, I think the issue happens with any reload of the grid (filtering, sorting, etc)

Thanks again tony for such a great plugin.

18/05/2012
09:25
Avatar
maxfelipe
Member
Members
Forum Posts: 3
Member Since:
18/05/2012
sp_UserOfflineSmall Offline

Looks like I answered my own question, or at least a way to make it work. Looks like since I was using json data with loadonce: true, the id lookup for a reload was using the "localReader" id, which defaults to _id_(in our case 'idPrefixxx'). The reload then concatenates the idPrefix with the id retrieved from the row, leading to a duplicated idPrefix. If we use key:true in a col in our model that also represents the id of the row, we are all set, as the reload method will take *that* id instead of the rowid. 

I still think there is an issue with how the rowid is constructed, as we should never end up with a duplicated idPrefix

Saludos desde Costa Rica

Max

18/05/2012
11:28
Avatar
maxfelipe
Member
Members
Forum Posts: 3
Member Since:
18/05/2012
sp_UserOfflineSmall Offline

Shouldn't also this line be reversed on addRowData:

id = rowid;

rowid  = t.p.idPrefix + rowid;

Done this way, when used with local data we are not really referencing the data array correctly.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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