Tal
Tal

Reputation: 391

jqGrid - datepicker fail on multiple grids when same column name is used is each grid

When having multiple grids on the same page, where each of the grids is having the same name for the date column (eg 'start_date'), the datepicker choose only the first one.

I know this is the nature of DOM elements, and I was wondering if there is a way to overcome this without changing the colModel.name, as this will also force me to parse the JSON data coming from the server (I don't have any control of the data returned from the server).

Upvotes: 0

Views: 650

Answers (1)

Oleg
Oleg

Reputation: 221997

If I correctly understand your problem then the most easy way to fix the problem would be to use different column names in multiple grids. If you load the data from the server you can use jsonmap property in colModel. For example

{ name: "grid1_column1", jsonmap: "propName", ... }

and

{ name: "grid2_column1", jsonmap: "propName", ... }

As the result you will have no conflicts in any searching of editing fields. The exact format of jsonmap can depend on the format of input data (the format of the server response) which you use.

I would recommend you to use additionally idPrefix with different values in multiple grids. For example idPrefix: "grid1_ and idPrefix: "grid2_. It will prevent conflicts in case of usage native id values for rows of both grids.

Upvotes: 1

Related Questions