Closed Mori0005 closed 1 year ago
Same issue here.
I have upgrade to 5.0.2 and it was the same.
I could solve the added jpg
in the client. But the counting up and not resetting the id , is the main issue.
Is there any work around. Thanks
Is this issue reproducible with /struts2-jquery-grid-showcase
?
I have tested this on live site at: https://struts.jgeppert.com/struts2-jquery-showcase/index.action and there was no error there.
For example , on gird -> grid menu, I type in the browser console
rows = $("#gridtable").jqGrid('getDataIDs');
and I get
(15) ['242', '168', '249', '237', '276', '465', '206', '348', '103', '471', '114', '333', '256', '406', '198']
But in my projects with above command I get:
(6) ['jqg1', 'jqg2', 'jqg3', 'jqg4', 'jqg5', 'jqg6']
Could you share your code? Or some example app?
The jsp has a grid is as below:
<sjg:grid id="gridtable" gridModel="gridModel"
rownumbers="true"
hoverrows="false" altRows="true" altClass="rowalt" href="%{url}" >
<sjg:gridColumn name="accountNo" title="%{accountNumberTitle}"
sortable="false" displayTitle="false" />
<sjg:gridColumn name="accountType" title="%{accountType}"
sortable="false" displayTitle="false" />
<sjg:gridColumn name="accOpeningBranchNo" title="%{accOpeningBranchNo}"
sortable="false" displayTitle="false" />
</sjg:grid>
it also has link:
<a id="sendDataBtn" onClick='callConfirmLink();' type="button" > confirm </a>
and it has some js
// to enable drag-drop
$('#gridtable').on('sortstart', function( e, ui ) {
ui.helper.addClass("grid-drag");
});
//trys to get data from grid and send it to server
function callConfirmLink() {
var rows = $("#gridtable").jqGrid('getDataIDs');
var accounts = {
'accountListVO' : []
};
for (var i = 0; i < rows.length; i++) {
row = $('#gridtable').jqGrid('getRowData', rows[i]);
accounts.accountListVO.push({
"order" : rows[i],
....
});
}
@afattahi54 what version of Struts do you use?
It is 6.1.1
I have tested this issue on 5.0.3-SNAPSHOT and same issue there too.
Did you try to use the plugin with Struts 6.2.0-SNAPSHOT?
I have tested with struts 2 6.1.2
and struts2 jquery plugin 5.0.3-SNAPSHOT
and the issue was there.
And, I have tested with struts 2 6.2.0-SNAPSHOT
and struts2. query plugin 5.0.3-SNAPSHOT
and the issue was there too.
Looks like it isn't a Struts issue, jQuery has changed logic around this, could you define the following column
<sjg:gridColumn name="id" index="id" title="ID" width="30" formatter="integer" sortable="false" displayTitle="false"/>
?
The output is NAN
for all rows.
Let me mention that the rows ids are showed correctly in the grid, but the $("#gridtable").jqGrid('getDataIDs');
is increasing when I revisit the page
Here are the pics:
First time the gird is ok and the $("#gridtable").jqGrid('getDataIDs');
in the console is ok too
Second time the grid ui is ok but the the $("#gridtable").jqGrid('getDataIDs');
starts from 20
When I create a sample grid WITHOUT using the s:grid
tag directly by $("#gridtable").jqGrid({datatype: "local", ...
the $("#gridtable").jqGrid('getDataIDs');
command works fine.
Hope this could help:
I have put breakpoint in jquery.jqGrid.js
method getDataIDs
line 6529
here is the this.rows
for first time:
here is the this.rows
for first second time:
As you can see in second image the rows start from 11
Just to be clear, this isn't the plugin code itself, it's a part of the jqGrid plugin and the logic around IDs has changed. That's why I suggest to use the same approach as in the grid showcase app.
Dear @lukaszlenart you are right 👍
After many :) searches I found that:
The
rowid
are used as a parameter of almost all callbacks and events of jqGrid. Because of that jqGrid must assign id attribute to every row and the input data of the grid have to contain rowid information! Therowid
is common over all grids and subgrids on the page.
A quick BAD solution is to $.jgrid.guid =1;
Another solution which shows gets the row id
rows[i].slice(3)-($.jgrid.guid-rows.length - 1) ,
It first gets the generated row ids which are always increments $("#gridtable").jqGrid('getDataIDs');
Since struts jQuery-gride-plugin 5.0.1 the "rows[i]" has have a "jqg" string at the beginning, this must be removed.
Then it minuse the last number of rows from array length to get the grid Ids
Here is a complete code.
var rows = $("#gridtable").jqGrid('getDataIDs');
for (var i = 0; i < rows.length; i++) {
var thisGridIds = rows[i].slice(3)-($.jgrid.guid-rows.length - 1)
});
Great to hear that you finally found a solution, can we close this issue?
of course thanks for help :)
Hi,
I found jqgrid table row id becomes strange behavior.
Struts2 2.5.x : event.originalEvent.id = 1,2,3...
Struts2 6.0.1 : event.originalEvent.id = jpg1,jqg2,jpg3...
Also, If I refresh the data of the table, (20 rows per page), id becomes as the following: event.originalEvent.id = jpg21,jqg22,jpg23...
and then after another refresh.. event.originalEvent.id = jpg41,jqg42,jpg43...
it seems counting up. any way to get previous format id ?