ekondur / DatatableJS

Jquery datatable with entity framework using MVC html helper
MIT License
36 stars 15 forks source link

Error when set selected table with checkbox #136

Closed nazerulgit closed 2 months ago

nazerulgit commented 3 months ago

when i set table to use .Selecting(true, SelectItems.Checkbox) this will be return error

An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object.

this error will not showing up when i set selecting to this options .Selecting(true) .Selecting(true, SelectItems.Cell, SelectStyle.Single)

this is my complete view @(Html.JS().Datatable() .Class("table table-hovered table-striped dataTable") .Name("datatable") .LengthMenu(new int[] { 5, 10, 25, 50, 100 }, true, "All Pages") .FixedColumns(leftColumns: 0, rightColumns: 1) .ColumnSearching(true, "form-control", SearchPosition.Header) .Columns(cols => { cols.Field(a => a.stu_Id).Title("Id"); cols.Field(a => a.stu_PerId).Title("Id"); cols.Field(a => a.stu_AdmitDate).Title("Admit Date"); }) .ColReorder(true) .URL(Url.Action("GetStudentNotYetEnroll"), "POST") .ServerSide(true) .Selecting(true, SelectItems.Checkbox) .StateSave(true) .Orders(order => { order.Add(p => p.stu_Id, OrderBy.Descending); }) .Render() )

Regards Nasrul

ekondur commented 2 months ago

Hi @nazerulgit It is fixed with version 3.8.2, thank you for your contribution!

nazerulgit commented 2 months ago

hi @ekondur

Now it is working well. Thank you very much.

However, this library would be very helpful if it had a function to check all checkboxes, and when one or more checkboxes are selected, it could trigger a callback to show a button. When this button is clicked, it will send the values of the selected checkboxes to the controller.

Thank you once again. Your library is very useful.

regards Nasrul

ekondur commented 2 months ago

Hi @nazerulgit Thank you for your advice, we can add a button for all selected, but your other suggestions seem user-specific and it seems more correct that you manipulate them