glitch when using with ASP.NET MVC
glitch when using with ASP.NET MVC
Hello,
I have implemented dataTables into my ASP.NET MVC project where I render a table using EditorFor() display templates. Therefore, what is happening is I have a model, which has a list of model objects loading as rows into the table (accounts model loads a list of person models as display templates to the table). The problem I am having is that dataTables deletes the models when using the next, previous and the search features. It is really strange, because the rows are still there, but when posting to the controller, the list of models attribute is null. However, If I load the first 30 models on page, and dont use one of these features, the post will contain the first 30 models. Is there any way to keep all the models? Otherwise this wont be able to hold much functionality for MVC besides displaying for items.
I have implemented dataTables into my ASP.NET MVC project where I render a table using EditorFor() display templates. Therefore, what is happening is I have a model, which has a list of model objects loading as rows into the table (accounts model loads a list of person models as display templates to the table). The problem I am having is that dataTables deletes the models when using the next, previous and the search features. It is really strange, because the rows are still there, but when posting to the controller, the list of models attribute is null. However, If I load the first 30 models on page, and dont use one of these features, the post will contain the first 30 models. Is there any way to keep all the models? Otherwise this wont be able to hold much functionality for MVC besides displaying for items.
This discussion has been closed.
Replies
Can you link use to the page please so I can take a look at the issue and hopefully suggest a fix.
Allan
@model project.Models.OrdersModel
Account
$(document).ready(function () {
$("#orders").dataTable();
});
.section
{
padding-bottom:10px;
padding-top:10px;
}
#loadingGif
{
border:solid;
border-color:Black;
border-radius: 15px;
border-width:2px;
border-style:outset;
width:60px;
height:60px;
background-color:White;
-webkit-box-shadow:5px 2px 2px #bbb;
}
List of People:
@using (Html.BeginForm("SearchPeople", "People", FormMethod.Post))
{
<!--
List of People
-->
CheckBox
Name
@Html.EditorFor(x => x.People)
}
[/code]
As you see, this is an Account Model, which holds a list of List (Person Models). The EditorFor() will insert this partial view below for each person model in the list.
[code]
@model Project.Models.PersonModel
@Html.CheckBoxFor(m => m.IsChecked)
@Model.Name
[/code]
So, what im trying to say, is that the list of person models above, the partial view from a list, doesn't work with dataTables. Try it yourself. try to update any item while using the next, previous, or search feature and it will post the null value in the List field.
Allan