I m facing a issue in Jqgrid with row selection. I have duplicated rows in the grid. whenever i select the duplicate or it select the first record of that duplicate row.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- MVC-Routing,Why i can not ignore defaults,The matc
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
It's common problem for many people who start to use jqGrid. Such strange selection behavior exist if you fill the grid with rows having id duplicates. So it's extremely important to understand how the ids from your input will be used by jqGrid.
jqGrid use internally HTML markup to display the grid. It uses
<table>
,<tbody>
(the body of the table - has no column headers),<tr>
(row of the table) and<td>
(table of the table) for any grid. The HTML fragment below could represent your grid for exampleThe design of jqGrid is so that one can have quick access to any row of the grid. To implement the quick access one need assign to every
<tr>
(table row) an unique id. You will find rowid parameters in the most methods or events used by jqGrid. The id of the row should identify the row in the set of the rows of the table. In the case the grid will be like the followingAccording to the HTML specification the id of any HTML element must be unique on the page. If you do assign duplicate ids to the rows like here for example
the table could be still displayed in the most web browsers, but the working with the grid could be really problematic. For example if you select the last row of such grid the corresponding jqGrid code will find out 15 as the id of the current row and it will use
$("#15").addClass("ui-state-highlight")
to highlight the current row. Instead of that the code will select (add the class "ui-state-highlight") only to the first row which has the id="15".So you should be very careful if you fill your JSON data used as the jqGrid input. The following data for example could represent the grid contain:
The JSON data could be fixed to
or to
for example. Then the world (inclusive the grid) will become OK.