jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Checkbox selection – get field_id
Tagged: grid, jquery grid, jqwidgets grid, jqxgrid
This topic contains 13 replies, has 2 voices, and was last updated by Peter Stoev 8 years, 11 months ago.
-
Author
-
I am nearly there, but the selection only applies on the pagination 1 page, I am using ` selectionmode: ‘checkbox’,
$(‘#jqxgrid’).bind(‘rowselect’, function (event){
var rows = $(“#jqxgrid”).jqxGrid(‘selectedrowindexes’);
var selectedRecords = new Array();
var value = new Array();
for (var m = 0; m < rows.length; m++) {
var row = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, rows[m], “zlec_id”);
selectedRecords[selectedRecords.length] = row;
}
console.log(selectedRecords);});`
How can I get also all the other records from the table? Thanks in advice
Hi kavvson,
There is built-in checkbox selection which is applied to all pages by default.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/I use it, but this console.log(selectedRecords); returns me only id’s from the first page and after that(page 2+) null’s
Hi kavvson,
I see no such behavior with the current version: http://jsfiddle.net/jqwidgets/xed3bxkc/
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/$("#button").click(function() { var rows = $("#jqxgrid").jqxGrid('selectedrowindexes'); var selectedRecords = new Array(); for (var m = 0; m < rows.length; m++) { var row = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "zlec_id"); selectedRecords[selectedRecords.length] = row; } console.log(rows); [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30] console.log(selectedRecords); ["196", "195", "193", "114", "113", "104", "103", "102", "101", "100", "99", "98", "90", "89", "86", "82", "78", "77", "76", "75", "74", "73", "72", "71", "70", null, null, null, null, null, null] } );
After 25 entries it returns null – 25 is the page size of pagination
As you see it doesn’t work, is it possible to override the selectedrowindexes with a column value?Hi kavvson,
Another working sample: http://jsfiddle.net/jqwidgets/z9uhz259/ If the same does not work for you, upgrade to the current version as the working sample is based on it. Same sample with Paging and select all: http://jsfiddle.net/jqwidgets/mvpbcbxr/
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Well the reason behind this I am using server side generated data, so he simply doesn’t sees the data unless hitting the second page… Any ideas how to solve that? If possible
Hi kavvson,
If the data is loaded on demand, the Grid will not be able to guess what the data is. You should better make AJAX call to retrieve a record from the server.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Well, frankly I got no idea where to start from, what would be the best solution for this?
Hi kavvson,
You can use jQuery AJAX function to get data from your server. In your scenario, you should write a function on your server which gets ID/Index as param and returns data. From the script, you will make AJAX call which sends as param a selected row index. Otherwise, I don’t see a way to get data which is not loaded.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/I think this is connected with JS, even when I select rows on first page and then would jump to second page, the selection only returns the second page rowdata’s
Hi kavvson,
When you load data on demand, the loaded data is what you see on the current page. I think you should either listen to my advice or load all your data at once.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/But sadly there is no examples of such implementation, as You suggested.
Hi kavvson,
I gave you the suggestions. However, the business logic should always be written by the developer.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.