mardi 14 juillet 2015

MVC3 model is null if Datatable filtering is applied

I'm using the jQuery Datatable ( for styling, sorting and filtering of list of data.

My razor is like [ which list a set of items and allow user to edit name and aim to save all changes to Db on single GO]

@using (Html.BeginForm()) {
            <legend>Modify items</legend>
                <input type="submit" value="Save" />
        <table cellpadding="0" cellspacing="0" border="0" class="" id="SelectEmpTable"> 
                    <th>Old Name</th>
                    <th>New Name</th>
            @for (int i = 0; i < @Model.Count();  i++)
                <td class="editor-label">
                    @Html.DisplayForm(m => m[i].Name)                       
                    @Html.HiddenFor(m => m[i].Id)
                     @Html.TextBoxFor(m => m[i].Name) //allow user to edit

and then use the jQuery plugin for the rest...

$(document).ready(function() { 
} );

When posting back without filtering the table (on the client side) my model is populated.

    public ActionResult SubmissionForm(IList<CompanyModel> model)
        //model is not null and has all list of values

However when filtering the table, and then submit form , the model is then null, in the above code.

How can i make sure both filtering is possible and get data in model while submitting form

Aucun commentaire:

Enregistrer un commentaire