I want to enable mutiple selection on my grid and I want to get the primary keys of the multiple selected rows which I want to pass down to my controller's ActionMethod.
-------------------------------------------------------------------------------------------------------------------
In single selection i used this method to get the primary key of my selected row:
// function rowSelectionChangedHandler(evt, ui) { var input = document.getElementById("hdnSelectedRow"); //input.value = ui.row.index; // Will pass the row index. input.value = ui.row.element.attr("data-id"); // Will pass the row's primary key.. } // ]]>
------------------------------------------------------------------------------------------------------
Now how do i get all the primary keys of the selected rows and get them as parameters in my mvc controller's action method.
And is there a way to pass all the primary keys of selected rows by storing them in a single hidden field like i did for single selection ? Because i dont wan to use ajaxPost to send these value to my actionmethod because it would get messy afterwards. iPlease share a small code snippet, thanks in advance
Hello,
Thank you for contacting us!
About your questions, how to get all primary keys of the selected rows, and pass them to action method, my suggestion is to use BeginForm and HiddenField. On Postback this BeginForm with call your action method and will pass like a parameter all primary keys of the selected rows. I have created a sample for you in order to show you this approach, on the page you can see Grid with products and a button which will invoke postback and will call your action method. In order to get the selected rows I use grid selection option "selectedRows".
Code snippet (View):
Code snippet (Controller):
Useful references:
https://www.igniteui.com/help/14.1/iggrid
https://www.igniteui.com/help/api/2014.1/ui.iggrid#options
If I can be of further assistance, contact me.
Great, thanks.
I am glad that I've managed to help you.
Thank you for using our products.