这是我的网格代码。如果我设置了新的数据源,然后添加行按钮,则日期选择器不起作用。
var source1;
function populateCourierTable(data) {
//alert("courier "+JSON.stringify(data));
source1 = {
localdata : data,
datafields : [ {
name : 'courier_id',
type : 'integer'
}, {
name : 'date',
type : 'date'
}, {
name : 'name',
type : 'string'
}, {
name : 'coming_from',
type : 'string'
}, {
name : 'pod_no',
type : 'string'
}, {
name : 'courier_name',
type : 'string'
}, {
name : 'remark',
type : 'string'
} ],
datatype : "json",
addrow: function (rowid, rowdata, position, commit) {
//alert("add");
//alert(JSON.stringify(rowdata));
var rowdt=JSON.stringify(rowdata);
$.ajax({
type : 'POST',
url : rootURL + '/addCourier',
data: {
rowdt : rowdt
},
dataType : "json",
success : function(data) {
if(data == "success"){
alert("added successfully");
commit(true);
}
},
error : function(res){
alert(JOSN.stingify(res));
}
});
}
};
var dataAdapter = new $.jqx.dataAdapter(source1);
$("#jqxgrid").jqxGrid({
width : 1250,
Height : 410,
source : dataAdapter,
//pageable : true,
//showtoolbar : true,
selectionmode : 'singlecell',
columnsresize : true,
sortable: true,
// filterable: true,
showeverpresentrow: true,
everpresentrowposition: "top",
everpresentrowactions: "add reset",
// showfilterrow: true,
// everpresentrowactionsmode: "columns",
columns : [{
text : 'Date',
cellsformat : 'dd-MM-yyyy',
filtertype : 'range',
datafield : 'date',
width : 170,
createEverPresentRowWidget: function (datafield, htmlElement, popup, addCallback) {
var inputTag = $("<div style='border: none;'></div>").appendTo(htmlElement);
inputTag.jqxDateTimeInput({ value: null, popupZIndex: 99999999, placeHolder: "Enter Date: ", width: '100%', height: 30,formatString: 'dd-MM-yyyy' });
$(document).on('keydown.date', function (event) {
if (event.keyCode == 13) {
if (event.target === inputTag[0]) {
addCallback();
}
else if ($(event.target).ischildof(inputTag)) {
addCallback();
}
}
});
return inputTag;
},
initEverPresentRowWidget: function (datafield, htmlElement) {
},
getEverPresentRowWidgetValue: function (datafield, htmlElement, validate) {
var value = htmlElement.val();
return value;
},
resetEverPresentRowWidgetValue: function (datafield, htmlElement) {
htmlElement.val(null);
}
}, {
text : 'Name',
columntype : 'textbox',
filtertype : 'input',
datafield : 'name',
width : 170
}, {
text : 'Coming From',
columntype : 'textbox',
filtertype : 'input',
datafield : 'coming_from',
width : 170
}, {
text : 'POD No',
columntype : 'textbox',
filtertype : 'input',
datafield : 'pod_no',
width : 170
}, {
text : 'Courier Name',
columntype : 'textbox',
filtertype : 'input',
datafield : 'courier_name',
width : 170
}, {
text : 'Remark',
columntype : 'textbox',
filtertype : 'input',
datafield : 'remark',
width : 170
} ]
});
source1 = null;
dataAdapter = null;
}
当我添加新数据源时,行已更新,但未更新工作日期选择器并添加行函数first image was working fine and second image I update datas then not working new row add button and date picker
$.ajax({
type : 'POST',
url : rootURL + "/filterData",
data : {
name : name,
comingFrom : comingFrom,
fromDate : fromDate,
toDate : toDate,
POD : POD,
IDNo : IDNo,
reportName : reportName,
mobileNo : mobileNo
},
dataType : "json",
success : function(data) {
globalReportData = data;
$('#jqxgrid').jqxGrid('refresh');
source1.localdata = data;
$("#jqxgrid").jqxGrid({ source: source1 });
}
});