Open orhoncms opened 8 years ago
Hey,
What you have currently would not actually set the row state as checked
behind the scenes - it would only appear selected on the front end I believe. You can test that by calling
var mySelectedRows = $('#myGrid').bootgrid('getSelectedRows');
// mySelectedRows = []
You could do this however from your initialization chunk without modifying bootgrid. The idea is to capture the checked
property of your rows and then call bootgrid's underlying select
method to set everything correctly. An example is below:
var grid = $("#grid").bootgrid({
ajaxSettings: {
method: "GET"
},
ajax: true,
url: 'http://127.0.0.1:8080/demo/data.json',
selection: true,
multiSelect: true
}).on('loaded.rs.jquery.bootgrid', function(){
var rows = grid.bootgrid('getCurrentRows');
$.each(rows, function(index, row){
if(row.checked){
grid.bootgrid('select', [row.id]);
}
})
});
You could also collect all the selected row id's first and then pass them into the select
call all at once in the parameter array. see select method
Always best to try to accomplish what you need without modifying your plugins in my opinion, so I feel this is a more maintainable solution for now.
Feel free to let me know if this works for you or if there is anything else i can do.
--][--
I can't set the table rows was selected from the json data.
So I changed the source code to fixed my program. chaged the code in line 602 like this :
And in json data:
is there some better suggestion to do it ? thanks