Filled Model and populating datatable

Filled Model and populating datatable

amun1000amun1000 Posts: 7Questions: 1Answers: 0
edited May 2014 in DataTables 1.9

Hi I'm in the middle of updating a site and now no longer require to fill the datatable using the following

var oTable = $('#parts-table').dataTable({
            "bServerSide": false,
            "sAjaxSource": "/Vehicle/GetParts",
            "sAjaxDataProp": "",
            "fnServerParams": function (aoData) {
                aoData.push({ "name": "id", "value": "@Model.Id" });
            },
            "bProcessing": true,
            "aoColumns": [
                            {
                                "sName": "Part",
                                "bSearchable": true,
                                "bSortable": true,
                                "mDataProp": "DisplayName",
                                "fnRender": function (oObj) {
                                    return oObj.aData.DisplayName;
                                }
                            },
                             {
                                 "sName": "Price",
                                 "bSearchable": true,
                                 "bSortable": false,
                                 "mDataProp": "Price",
                                 "fnRender": function (oObj) {
                                     return '<input type=\"text\" id=\"part-price-' + oObj.aData.Id + '\" value=\"' + oObj.aData.Price + '\" class=\"input-small\" ' + (oObj.aData.Status == 2 || oObj.aData.Status == 1 || oObj.aData.Status == 3 ? 'readonly=\"readonly\"' : '') + ' />';
                                 }
                             },
                              {
                                  "sName": "Notes",
                                  "bSearchable": true,
                                  "bSortable": false,
                                  "mDataProp": "Notes",
                                  "fnRender": function (oObj) {
                                      return '<textarea id="additional-notes-' + oObj.aData.Id + '\"  placeholder=\"additional notes...\" ' + (oObj.aData.Status == 2 || oObj.aData.Status == 1 || oObj.aData.Status == 3 ? 'readonly=\"readonly\"' : '') + ' />';
                                  }
                              },
                               {
                                   "sName": "Action",
                                   "bSearchable": true,
                                   "bSortable": false,
                                   "mDataProp": "Guaranteed",
                                   "fnRender": function (oObj) {
                                       return buildActionButtons(oObj);
                                   }
                               }
            ],

However the model on the Razor view already has the available collection(@Model.Parts) so no Ajax request required. How do i fill the table using the available collection on the model (@Model.Parts)

many thanks

Andrew

This discussion has been closed.