jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Not able to create a row in JqxGrid
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 10 years, 12 months ago.
-
Author
-
Hi, I am not able to create a row when I click the button.Can you please tell whats going wrong in this?
function initializeCaseSubmissionGrid(dataAdapter) {
$jqxCsSubmmisionDateGrd = $(“#jqxGridSubmmisionDate”);
$jqxCsSubmmisionDateGrd.jqxGrid({
width: “100%”,
source: dataAdapter,
editable: false,
showheader: false,
autoheight: true,
columns: [
{
datafield: ‘submissiondatesid’,
hidden:true,
width: “20%”
},{
datafield: ‘submissionshowid’,
width: “20%”
}, {
datafield: ‘submissiondate’,
cellsformat: ‘dd-MMM-yyyy’,
formatString: ‘dd/MM/yyyy’,
width: “70%”
}, {
text: ”,
width: “10%”,
columnsreorder:false,
cellsrenderer: function (row) {
return ‘‘;
}
}
]
});}
DeleteRow=function(event) {
var selectedrowindex = parseInt(event.target.id);
var submissionID=$(“#jqxGridSubmmisionDate”).jqxGrid(‘getrowdatabyid’, selectedrowindex);
if(typeof submissionID.submissiondatesid!=’undefined’){
alert(‘deleted’);
}
var commit = $(“#jqxGridSubmmisionDate”).jqxGrid(‘deleterow’, selectedrowindex);
$(“#jqxGridSubmmisionDate”).jqxGrid(‘refreshData’);
}function addSubmissionDate(){
var count=1;
$(“#btnCreateRow”).click(function (){
//var datarow = {“submissiondatesid”:”,”submissionshowid”: count ,”submissiondate”: $.datepicker.formatDate(‘dd-M-yy’,new Date($(this).val()))};
var datarow ={};
datarow[‘submissiondatesid’]=”;
datarow[‘submissionshowid’]=count;
datarow[‘submissiondate’]=$.datepicker.formatDate(‘dd-M-yy’,new Date());$(“#jqxGridSubmmisionDate”).jqxGrid(‘addrow’, null, datarow);
$(“#jqxGridSubmmisionDate”).jqxGrid(‘refreshData’);
count=count+1;});
}function bindCaseSubmissionData(data) {
/*var data = [
{“submissionshowid”: “1st”,”submissiondate”: “22-May-2014”},
{“submissionshowid”: “2nd”,”submissiondate”: “01-Feb-2014”}
]; */
var submissionSource = {
localdata:data,
datatype: “json”,
datafields: [{
name: ‘submissiondatesid’,
type: ‘string’
}, {
name: ‘submissionshowid’,
type: ‘string’
},{
name: ‘submissiondate’,
type: ‘date’
}],
addrow: function (rowid, rowdata, position, commit) {
commit(true);
}
//id: ‘SubmissionID’
};
var dataAdapter = new jQuery.jqx.dataAdapter(submissionSource);
initializeCaseSubmissionGrid(dataAdapter);}
}Hello Syai,
Is there any error thrown in the console when you click the btnCreateRow button?
Looking at your code, here is what might be causing the issue:
1) In the line:
datarow['submissiondatesid']=”;
instead of two quotes for an empty string you have only one.2) And in the line:
datarow['submissiondate']=$.datepicker.formatDate(‘dd-M-yy’,new Date());
you call a jQuery UI method. Maybe you have not referenced some of this library’s files?Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.