Click here to Skip to main content
14,209,015 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello

I have a table that is populated by using a for loop and contains text boxes that can be edited and the changes can be posted back to the server. It works fine unless I filter the table using the search bar which posts back to the model as null. Im assuming it is because I need to reinitialise the table with the filter values but im not sure how to do this while keeping it editable at the same time.

Thanks

What I have tried:

<table id="datatable-nic" class="table table-condensed no-footer datatable-basic-noPage">

                      <thead>
                          <tr>

                              <th>Description</th>
                              <th>Letter Type</th>
                              <th>Mail Type</th>
                              <th>Fold</th>
                              <th>Print Cost </th>
                              <th>Fulfilment Cost</th>
                              <th>Postage Cost</th>
                          </tr>
                      </thead>

                      <tbody id="myTable">

                          @for (int i = 0; i < Model.Count; i++)
                          {

                              <tr>


                                  @Html.HiddenFor(m => Model[i].LetterType, new { @class = "form-control", @readonly = "readonly" })



                                  <td class="exp" data-search='@Model[i].Description'>@Html.TextBoxFor(m => Model[i].Description, new { @class = "form-control", @readonly = "readonly" })</td>


                                  <td data-search='@Model[i].LetterType'>@Html.TextBoxFor(m => Model[i].LetterType, new { @class = "form-control", @readonly = "readonly" })</td>


                                  <td data-search='@Model[i].MailType'>@Html.TextBoxFor(m => Model[i].MailType, new { @class = "form-control", @readonly = "readonly" })</td>


                                  <td data-search='@Model[i].Fold'>@Html.TextBoxFor(m => Model[i].Fold, new { @class = "form-control", @readonly = "readonly" })</td>


                                  <td data-search='@Model[i].PrintCost'>@Html.TextBoxFor(m => Model[i].PrintCost, new { @class = "form-control", autocomplete = "off" })</td>


                                  <td data-search='@Model[i].FulfilmentCost'>@Html.TextBoxFor(m => Model[i].FulfilmentCost, new { @class = "form-control", autocomplete = "off" })</td>


                                  <td data-search='@Model[i].PostageCost'>@Html.TextBoxFor(m => Model[i].PostageCost, new { @class = "form-control", autocomplete = "off" })</td>

                              </tr>
                          }
                      </tbody>
                  </table>
              </div>
                      <div>
                          <div class="col-md-12 col-sm-12">
                              <button type="submit" class="btn btn-success pull-right"> Submit</button>
                          </div>
                      </div>


      @section scripts{
      <script src="~/Scripts/select2.min.js"></script>
      <script src="~/Scripts/DataTables/datatables.min.js"></script>
 }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190617.1 | Last Updated 23 Jan 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100