how to update table after CRUD opertion
how to update table after CRUD opertion
parthi
Posts: 1Questions: 0Answers: 0
var url = '@Url.Action("AdminProductSearchGrid", "AdminProductSearch")';
var data1 = {}
$.ajax({
'type': "POST",
'global': false,
'dataType': 'json',
'async': false,
'url': url,
'data': data1,
'deferRender': true,
'success': function (data) {
Arr = JSON.parse(data);
var item = '';
var Sno = 0;
if (Arr.Table.length == 0) {
item += '<tr><td colspan="10" style="text-align:center">No records found.</td></tr>';
}
else {
table = $('#example').DataTable(
{
data: Arr.Table,
columns: [
{
title: "#", render: function (data, type, row, rowcount) {
return rowcount.row + 1;
}
},
{
data: "Category", title: "Collection", style: "width:56px;", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "' >" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "SubCategory", title: "Sub Collection", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "Productname", title: "Product Name", render: function (data, type, row) {
if ((data + ' ' + row.Widthfeet + 'X' + row.Lengthfeet + '|' + row.Itemno + '').length > 10) {
return "<span title='" + (data + ' ' + row.Widthfeet + 'X' + row.Lengthfeet + '|' + row.Itemno + '') + "'>" + (data + ' ' + row.Widthfeet + 'X' + row.Lengthfeet + '|' + row.Itemno + '').substring(0, 10) + '..'; +"</span>";
}
return data + ' ' + row.Widthfeet + 'X' + row.Lengthfeet + '|' + row.Itemno + '';
}
},
{
data: "Itemno", title: "Item #", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "Lengthfeet", title: "Length", render: function (data, type, row) {
if ((data + ' ft ' + row.Lengthinches + 'in' + '').length > 10) {
return "<span title='" + (data + ' ft ' + row.Lengthinches + 'in' + '') + "'>" + (data + ' ft ' + row.Lengthinches + 'in' + '').substring(0, 10) + '..'; +"</span>";
}
return data + ' ft ' + row.Lengthinches + 'in' + '';
}
},
{
data: "Widthfeet", title: "Width", render: function (data, type, row) {
if ((data + ' ft ' + row.Widthinches + 'in' + '').length > 10) {
return "<span title='" + (data + ' ft ' + row.Widthinches + 'in' + '') + "'>" + (data + ' ft ' + row.Widthinches + 'in' + '').substring(0, 10) + '..'; +"</span>";
}
return data + ' ft ' + row.Widthinches + 'in' + '';
}
},
{
data: "Design", title: "Design", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "Style", title: "Style", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "Origin", title: "Origin", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
},
{
data: "Type", title: "Type", render: function (data, type, row) {
if (data.length > 10) {
return "<span title='" + data + "'>" + data.substring(0, 10) + '..'; +"</span>";
}
return "<span>" + data + "</span>";
}
}, {
data: "ProductID", title: "Action", "orderable": false, render: function (data, type, row, rowcount) {
return '<i class="fa fa-pencil-square-o ActionButton" title="Edit" onclick="EditAdminProductEditID(' + data + ',2)" ></i> <i class="fa fa-times-circle ActionButton" title="Delete" onclick="EditAdminProductEditID(' + data + ',3)" ></i> ';
}
}
] //, "bDestroy": true
})
}
$('.se-pre-con').css({ 'display': 'none' });
}
});
}
This discussion has been closed.