DataTables has not rendering image - jquery-ui

i'm trying show image in datatable, but i have a troubles with rendering image, how i may fixed it?
i'm using Django
$(document).ready(function() {
var datatable = $("#asins_list").DataTable({
"bServerSide": true,
"sAjaxSource": links.ajax_get_asins_list,
"bProcessing": true,
"bLengthChange": true,
"bFilter": false,
'sDom': 'Bfrtip',
"bSortable": false,
"bSearch": false,
"autoWidth": true,
"ordering": false,
"bInfo": false,
"lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
"iDisplayLength": 10,
responsive: true,
"aoColumnDefs": [{
"targets": 0,
"data": "remark",
"render": function ( data, type, row, meta ) {
// return 'Download';
return '<a href="test.png"><img src="test.png" ' +
'><b>Competed</b></a>';
}
}],
});

You did not indicate which version you are using, so I assume its the latest (1.10.18).
In that case please note that aoColumnDefs no longer exists, it is now just ColumnDefs.

Related

JQGrid is not loading data in MVC 5?

I am using jqgrid and table is working correctly. But no data is loading and it continuesly displaying "loading...". It worked correctly but i maybe due to some reason it is not working now.
public JsonResult GetDetails()
{
Database1Entities db = new Database1Entities();
var jsondata = new
{
total = 1,
page = 1,
records = db.Employees.ToList().Count.ToString(),
rows = db.Employees.Select(a => new {
a.Id,a.Name,a.Designation,a.Address,a.Salary
})
};
return Json(jsondata, JsonRequestBehavior.AllowGet);
}
JQGrid function is below:
$(document).ready(function () {
$("#Grid").jqGrid({
url: '/Home/GetDetails',
datatype: 'json',
myType: 'GET',
colNames: ['id','Name', 'Designation', 'Address', 'Salary'],
colModel: [
{ key: false, name: 'Id', index: 'Id', },
{ key: false, name: 'Name', index: 'Name', editable: true },
{ key: false, name: 'Designation', index: 'Designation', editable: true },
{ key: false, name: 'Address', index: 'Address', editable: true },
{ key: false, name: 'Salary', index: 'Salary', editable: true }
],
jsonReader: {
root: 'rows',
page: 'page',
total: 'total',
records: 'records',
id: '0',
repeatitems: false
},
pager: $('#pager'),
rowNum: 10,
rowList: [10, 20, 30],
width: 600,
viewrecords: true,
multiselect: true,
sortname: 'Id',
sortorder: "desc",
caption: 'Employee Records',
loadonce: true,
}).navGrid('#pager', { edit: true, add: true, del: true },
{
zIndex: 100,
url: '/Home/Edit',
closeOnEscape: true,
closeAfterEdit: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText)
{
alert(response.responseText);
}
}
},
{
zIndex: 10,
url: '/Home/Add',
closeOnEscape: true,
closeAfterEdit: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
},
{
zIndex: 100,
url: '/Home/Delete',
closeOnEscape: true,
closeAfterEdit: true,
recreateForm: true,
afterComplete: function (response) {
if (response.responseText) {
alert(response.responseText);
}
}
}
);
});
If i add something, it works and data is inserted into database but the main problem is not data is shown in JQGrid. What is the problem?

jqgrid not showing any results when count exceeds ~9000

I am using jqgrid version 4.1.2 with MVC4, using loadonce option. When the search result's count exceeds approximately 9000 records, no data is shown up on the grid.
What might be the issue?
Here is the JS code: Update 1
function showCompletedGrid() {
// Set up the jquery grid
$("#jqTableCompleted").jqGrid({
// Ajax related configurations
url: jqDataUrl,
datatype: "json",
mtype: "POST",
loadonce: true,
loadtext: 'Loading Data please wait ...',
postData: { strUserName: function () { return $('#ddlUserName :selected').val(); },
strFunctionName: function () { return $('#ddlOPMSFunction :selected').text(); },
strProcName: function () { return $('#ddlOPMSProcess :selected').text(); },
strCategory: function () { return $('#ddlSearchCategory :selected').text(); },
strWorkType: function () { return $('#ddlSearchWorkType :selected').text(); },
strRequestNumber: function () { return $('#txtRequestNo').val(); },
strStatus: function () { return $('#ddlSearchStatus :selected').text(); },
strFromDate: function () { return $('#txtFromDate').val().toString(); }, //datepicker('getDate'),
strToDate: function () { return $('#txtToDate').val().toString(); }, //datepicker('getDate'),
strAction: "Closed"
},
autowidth: true,
shrinkToFit: true,
// Specify the column names
colNames: ["S.No.", "User Name", "Category", "Work Type", "Request Number", "Status", "Time Spent", "RE", "GUID", "Marked for Correction", "Correction Complete", "Reason", "Task Type", "acf2id", "Created Date", "Action", "IsTeam"],
// Configure the columns
colModel: [
{ name: "SNo", index: "SNo", sorttype: 'int', width: 100, align: "left", hidden: true, sortable: true, search: true, searchoptions: { sopt: ['eq']} },
{ name: "UserName", index: "UserName", width: 200, align: "left", sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "Category", index: "Category", width: 200, align: "left", sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "WorkType", index: "WorkType", width: 200, align: "left", sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "RequestNumber", index: "RequestNumber", width: 200, align: "left", sortable: true, search: true, searchoptions: { sopt: ['cn']} },
{ name: "Status", index: "Status", width: 200, align: "left", sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "TimeSpent", index: "TimeSpent", width: 200, align: "left", sortable: true, search: true },
{ name: "RE", index: "RE", width: 200, align: "left", sortable: true, search: true },
{ name: "GUID", index: "GUID", sortable: false, search: false, width: 200, align: "left", hidden: true },
{ name: "MarkCorrection", index: "MarkCorrection", width: 200, align: "left", hidden: true, sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "CorrectionComplete", index: "CorrectionComplete", width: 200, align: "left", hidden: true, sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "Reason", index: "Reason", width: 200, align: "left", hidden: true, sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "TaskType", index: "TaskType", width: 200, align: "left", sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "acf2id", index: "acf2id", width: 200, align: "left", hidden: true, sortable: true, search: true, sorttype: 'string', searchoptions: { sopt: ['cn']} },
{ name: "CreatedDate", index: "CreatedDate", width: 200, align: "left", hidden: false, search: false },
{ name: 'Actions', sortable: false, search: false, fixed: true, align: 'center', formatter: returnHyperLinkCompleted },
{ name: 'IsTeam', sortable: false, hidden: true, search: false, fixed: true, align: 'center' }
],
ignoreCase: true,
//width: 1250,
height: 150,
// Paging
toppager: true,
pager: $("#jqTableCompletedPager"),
//rowTotal: 200,
rowNum: 20,
rowList: [20, 15, 10, 5],
viewrecords: true,
emptyrecords: "",
hiddengrid: true,
// Default sorting
sortname: "SNo",
sortorder: "asc",
// Grid caption
caption: "Closed",
loadComplete: function (data) {
var RE;
var TimeSpent;
var rowIDs = jQuery("#jqTableCompleted").jqGrid('getDataIDs');
for (var i = 0; i < rowIDs.length; i++) {
var rowID = rowIDs[i];
var row = jQuery('#jqTableCompleted').jqGrid('getRowData', rowID);
RE = hmsToSecondsOnly(row.RE);
RE = (0.2 * RE) + RE;
TimeSpent = hmsToSecondsOnly(row.TimeSpent);
if (TimeSpent > RE && RE > 0) {
$(row).removeClass('ui-widget-content');
$(row).removeClass('ui-state-highlight');
$("#jqTableCompleted tr[id='" + rowID + "']").addClass('myColor');
}
}
}
}).navGrid("#jqTableCompletedPager",
{ refresh: true, add: false, edit: false, del: false },
{}, // settings for edit
{}, // settings for add
{}, // settings for delete
{sopt: ["cn"]}
);
$("#jqTableCompleted").jqGrid('navGrid', '#jqTableCompletedPager', { del: false, add: false, edit: false, search: false });
$("#jqTableCompleted").jqGrid('filterToolbar', { searchOnEnter: false, searchOperators: true });
$("#jqTableCompleted").jqGrid('navButtonAdd', '#jqTableCompletedPager',
{ caption: "Export to Excel", buttonicon: "ui-icon-extlink", title: "Export", id: "btnExport",
onClickButton: function (evt) {
var UserName = $('#ddlUserName option:selected').val();
var RequestNumber = $('#txtRequestNo').val();
var FunctionName = encodeURIComponent($('#ddlOPMSFunction option:selected').text());
var ProcessName = encodeURIComponent($('#ddlOPMSProcess option:selected').text());
var Category = $('#ddlSearchCategory option:selected').text();
var WorkTypeName = $('#ddlSearchWorkType option:selected').text();
var SearchStatus = $('#ddlSearchStatus option:selected').text();
var TransactionStartTS = $('#txtFromDate').val().toString();
var TransactionEndTS = $('#txtToDate').val().toString();
window.open("../Search/Export?UserName=" + UserName + "&RequestNumber=" + RequestNumber + "&FunctionName=" + FunctionName + "&ProcessName=" + ProcessName + "&Category=" + Category + "&WorkTypeName=" + WorkTypeName + "&SearchStatus=" + SearchStatus + "&TransactionStartTS=" + TransactionStartTS + "&TransactionEndTS=" + TransactionEndTS + "&ActionName=" + "Closed");
}
});
}
Although the data is being returned and in the correct format, from the controller, as follows, the grid does not show any result.
var jsonData = new
{
page = page,
rows = data
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
Also is there any limit on number of records or dependency on the browser when returning all the data from server using the loadonce option?
Any help would be much appreciated. Thanks.
Finally I found the solution for the above problem by tracing the request in Fiddler, in the response title following error was shown:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
Upon searching for the above error, I found a workaround:
Here
Basically the problem area was not the jqGrid, but was MaxJsonLength property of JavaScriptSerializer which defaults to 2097152 characters ~ 4 MB of data. Source: MaxJsonLength
To get it working, I replaced the following code in my Action method:
return Json(jsonData, JsonRequestBehavior.AllowGet);
with:
var jsonResult = Json(jsonData, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
Thanks.

Kendo Grid loading Slowly

I am Trying to load some grecords in to the kendo grid. If I am getting 10 records it is loading quickly. If I have more than 500 it is taking so much time to load.
Can any one help on this?
Below is my code:
$("#gridExistingpartners").kendoGrid({
columns: [{
field: "PARTNER_ID",
title: "#",
filterable: false,
width: 85
},
{
field: "NAME",
title: "Partner Name",
width: 185
},
{
field: "PARTNER_TYPE",
title: "Partner Type",
width: 100
},
{
command: { name:"View",text: "View", click: ViewExistingPartners },
title: "Edit",
width: 85
},
{
command: { name:"Add",text: "Add", click: AddExistingPartners },
title: "Add",
width: 85
}],
height: 250,
autoBind: true,
scrollable: true,
sortable: true,
serverPaging: true,
serverSorting: true,
serverFiltering: true,
refresh: true,
filterable: {
extra: false,
operators: {
string: {
startswith: "Starts with",
eq: "Is equal to",
neq: "Is not equal to"
}
}
},
pageable: {
refresh: true,
pageSizes: true,
buttonCount: 5,
pageSize: 15
}
});
One way to load data without paging and faster is using the scrollable option. Thus, the grid rows are loaded when you scroll down.
In grid options use:
scrollable: { virtual: true }
Read more here

JqGrid Edit & Delete button with each row

i m using jqgrid with mvc 3, I want to add Edit and Delete button with every row of JqGrid , i have achieved this thing by the help of this link. But it is for inline editing, i want to open a popup widows when click on edit button.
How can i achieve this thing.
Thanks
You should just use new editformbutton: true option which exists starting with version 4.1.0 of jqGrid:
formatter:'actions',
formatoptions: {
keys: true,
editformbutton: true
}
Please find the colmodel below for editing:
{
name: 'EditAction',
width: 60,
fixed: true,
search: false,
sortable: false,
resize: false,
formatter: 'actions',
formatoptions: {
keys: false,
editbutton: true,
delbutton: false,
editformbutton: false,
onSuccess: function(response) {
if (response.status == 200) {
}
},
extraparam: { oper: 'edit' },
url: '#Url.Action("ActionName", "Controller")'
}
},
jQuery("#grid").jqGrid({
datatype: "local",
data: second,
#url: '#Url.Action("orders", "Home")',
datatype: "json",#
colNames: ['name', 'description', 'url'],
colModel: [
{name: 'name',
index: 'name',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter a Name'}
},
{name: 'description',
index: 'description',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter description'}
},
{
name: 'url',
index: 'url',
editable: true,
editrules: {required: true},
editoptions: {placeholder: 'Enter url'}
}
],
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'model',
pager: '#pager',
editrow:true,
editurl: '#Url.Action("orders", "Home")',
viewrecords: true,
sortorder: "desc",
jsonReader: {
repeatitems: false,
id: "0"
},
searching: {
loadFilterDefaults: false,
closeOnEscape: true,
searchOperators: true,
searchOnEnter: true
},
caption: "Cars Grid",
height: '80%',
gridComplete: initGrid
});

Need help with problem with anonymous ids

i have:
var answers_json = [{
name: "email",
mapping: "answer.respondent.email"
}, {
name: "group",
mapping: "answer.respondent.respondent_group_id"
}, {
name: "text",
mapping: "answer.text"
}, {
name: "scale",
mapping: "answer.scale"
}, {
name: "created_at",
mapping: "answer.created_at",
type: "date",
dateFormat: "c"
}];
var answers_columns = [{
id: "email",
header: a_email,
width: 240,
sortable: true,
resizable: false,
menuDisabled: true,
dataIndex: "email",
//renderer: anonim_fun i need to write function?
}, {
id: "group",
header: "<div style=text-align:center>" + a_group + "</div>",
width: 55,
sortable: true,
resizable: false,
menuDisabled: true,
dataIndex: "group"
}, {
id: "text",
header: a_answer,
width: 550,
sortable: true,
resizable: false,
menuDisabled: true,
dataIndex: "text"
}, {
id: "scale",
header: a_scale,
width: 50,
sortable: true,
resizable: false,
menuDisabled: true,
dataIndex: "scale"
}, {
id: "created_at",
header: a_added_date,
width: 120,
sortable: true,
resizable: false,
menuDisabled: true,
dataIndex: "created_at",
xtype: "datecolumn",
format: "Y-m-d H:i:s"
}];
Problem is follow:
I have tables (as you can see) ..if respondent answered and he putted flag to (I ASK ANONYMOUS) then (IN MY VERSION) respondent_id gets 0 as id and in tale respondents there are user with some id called anonymous and then in extjs i see - anonymous (from respondent_id).
This works, but there are another way.. add field is_anonymous into inquiry table (relation between answers & respondents tables). but answers_json in column email get info about answer.respondent.email... How i can do another way with just adding field is_annonymous (and if yes = 1, if no = 0). this is much clever. But how it write in extJS? Function? AND HOW?
thanks!
You can use convert: as part of your field definition. Look at the current value and replace it with what you prefer.
{
name: "email",
mapping: "answer.respondent.email"
convert: function(val) {
if(val=="....") {
return "(anonymous)"
}
},

Resources