views:

31

answers:

1

When you have more than one jqGrid on the page at the same time, their child-element ids can conflict. You might want to have three or four identical grids stacked one above the other, showing the same data but from different years.

Child-element ids should have the table-id prepended to them. Is there a "fully-qualified|verbose ids" setting that does this?

Thanks

A: 

First of all I find your question very interesting, so +1 for the question. What you find out can be really large problem which can be difficult diagnosed. So I recommend you to place the corresponding suggestion in the feature request on http://www.trirand.com/blog/?page_id=393/feature-request/.

Now about the workaround possibilities. The easiest way is to generate an unique Ids for different grids on the server side. But it is of cause not always possible. You can add an id_prefix as an additional parameter of your server code which produce JSON/XML reply from jqGrid. Then server should add this prefix to all ids before sending back to jqGrid. This workaround is not nice but it will work.

Another way which I see is the changing of id of all jqGrids rows with respect of jsonReader (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#jsonreader_as_function). If you add to the jqGrid the parameter like following:

jsonReader: { id: function(obj) { return "BlaBla" + obj.id; } }

then all ids in the table will receive prefix "BlaBla". If you use jqGrids on your page only to display data in the grid this can be your solution. You should don't forget about possible new problems which produce this workaround. If you use master/detail scenario, Edit/Delete etc you have to take in consideration, that ids of grids will have prefixes now. So you will have to include additional code in evens like onclickSubmit, serializeRowData, serializeGridData and so on to cut the prefix before the usage of id or before sending ids to the server.

Oleg
Thanks for the suggestions, Oleg. I am using addRowData method at the moment $("#my-table").jqGrid('addRowData',i+1, data[i]); so I am temporarily up the creek without a paddle. I'd like to make the feature-request on the trirand blog but the WordPress "forgot password" mechanism seems to be broken. I've checked my spam folder too.
Tim
Sorry, but I don't understand how problems of WordPress are connected to the problems described in your question and with the feature-request on the trirand blog. If you have some technical problems to access trirand blog, I could do this for you (after you conform it explicitly). How I understand your comment with `addRowData` you has only local data and use no JSON and XML data input. So you are able on the client side define the ids. Is it correct? Do you try use 3.7.x version of jqGrid with `data` parameter? Then you not need use `addRowData` function. Is your problem with ids yet exists?
Oleg