Datatable Editor Implementation in ASP.Net MVC with Model Data

Datatable Editor Implementation in ASP.Net MVC with Model Data

victoworkvictowork Posts: 1Questions: 1Answers: 0

AM facing lot of troubles with editor implementation. I have a trial pack of Editor.

           <table id="demoGrid" class="table table-striped table-bordered" cellspacing="0" width="100%" >  
                    <thead>  
                  <tr>  
                      <th style="width:30px;"></th>
                      <th></th>
                    <th class="th-sm" id="stkcde">Stock Code</th>  
                     <th class="th-sm">Description</th>
                        <th>Color</th>
                     <th class="th-sm">Unit</th>   
                      <th class="th-sm">Qty</th> 
                      <th class="th-sm">Unit Price</th> 
                      <th class="th-sm"  id="price">Total Price</th> 
                    <th class="th-sm" id="discount">Discount</th>  

                </tr>  
                    </thead>  
                     <tbody>
                      @foreach (var item in Model)
                      {
                          <tr>
                              <td><i class="fa fa-plus-circle" aria-hidden="true"> &nbsp </i> 
              <i class="fa fa-minus-square" aria-hidden="true"></i></td>
                              <td>@item.RowNumber</td>
                              <td>@item.StockCode</td>
                             <td>@item.Description</td>
                              <td>@item.Unit</td>
                              <td>@item.Qty</td>
                              <td>@item.UnitPrice</td>
                              <td>@item.TotalPrice</td>
                              <td>@item.Discount</td>

                          </tr>
                      }
                  </tbody>
                </table> 

This is my Table Structure, and am giving the data by Razor through my model. My table initialization and editor is

$(document).ready(function () {
         t = $('#demoGrid').DataTable({
            "paging": false,
            "lengthChange": false,
            "info": false,
            "searching": false,
            "order": [[1, 'asc']],
            "columnDefs": [{
                "targets": [2,3],
                "render": $.fn.dataTable.render.ellipsis(10)
            }]
         });

editor = new $.fn.dataTable.Editor({

              table: "#demoGrid",
              fields: [{
                  label: "Stock Code:",
                  name: "StockCode"
              }
              ]
          });

Am calling the editor like

     $("#demoGrid").on('click', 'tbody td:not(:first-child)', function (e) {

                    editor.inline(this);
    });

Is the implementation is correct with mvc, or i need to do any thing else. Please help, if i did this my management will allow me to buy this datatable Extension.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You haven't explained what your "troubles" are. What is happening? Are you seeing error messages? Have you done any debugging?

  • allanallan Posts: 63,494Questions: 1Answers: 10,470 Site admin

    Yes, I don't immediately see anything wrong with the above, so if you could provide some more information that would be great. Ideally a link to the page you are working on, but if that isn't possible an explanation of the issues and any error messages would help.

    Allan

This discussion has been closed.