jQWidgets Forums
jQuery UI Widgets › Forums › Grid › error: Object Excepted
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 12 years, 7 months ago.
-
Authorerror: Object Excepted Posts
-
Hi
I am getting error code : “Object Excepted” while trying to add a row to grid. The error is displayed at “var datarow = generaterow(rowscount + 1); “.
This error is stopping me from creating new row.
$(“#addrowbutton”).bind(‘click’, function () {
var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
var datarow = generaterow(rowscount + 1); // Error here
$(“#jqxgrid”).jqxGrid(‘addrow’, null, datarow);
});Hello naveen,
The source of the issue seems to be the generaterow function. Could you, please, post it so we can better be able to help?
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Here is the code. Also Add Delete and update buttons are not working. Let me know if I am making any mistake in Jquery as I am a beginner for jquery.
$(document).ready(function () {
$.post(“getaccess.jsp”, {“processId”: $(“#procId”).val()}, function(data1){
var theme = getTheme();
// var data =
//var url = new Object();
var url = data1;
alert(url);
// prepare the data
var source =
{
datatype: “json”,
datafields: [
{ name: ’empId’ },
{ name: ‘fname’ },
{ name: ‘lname’},
{ name: ’empcat’},
{ name: ‘dept’},
{ name: ‘jTitle’},
{ name: ‘rAccess’},
{ name: ‘lManager’},
{ name: ‘sDate’},
{ name: ‘eDate’}
],
localdata: url,
addrow: function (rowid, rowdata) {
// synchronize with the server – send insert command
var data = “insert=true&” + $.param(rowdata);
$.ajax({
dataType: ‘json’,
url: ‘Testing.jsp’,
data: data,
success: function (data, status, xhr) {
// insert command is executed.
}
});
},
deleterow: function (rowid) {
// synchronize with the server – send delete command
var data = “delete=true&EmployeeID=” + rowid;
$.ajax({
dataType: ‘json’,
url: ‘Testing.jsp’,
data: data,
success: function (data, status, xhr) {
// delete command is executed.
}
});
},
updaterow: function (rowid, rowdata) {
// synchronize with the server – send update command
var data = “update=true&” + $.param(rowdata);
$.ajax({
dataType: ‘json’,
url: ‘Testing.jsp’,
data: data,
success: function (data, status, xhr) {
// update command is executed.
}
});
}
};var dataAdapter = new $.jqx.dataAdapter(source);
//, {
// downloadComplete: function (data, status, xhr) { },
//loadComplete: function (data) { },
//loadError: function (xhr, status, error) { }
//});
// initialize jqxGrid$(“#jqxgrid”).jqxGrid(
{
width: 1200,
source: dataAdapter,
theme: theme,
editable:true,
pageable: true,
autoheight: false,
columns: [
{ text: ‘Employee ID’, datafield: ’empId’, width: 90 },
{ text: ‘First Name’, datafield: ‘fname’, width: 140 },
{ text: ‘Last Name’, datafield: ‘lname’, width: 140 },
{ text: ‘Employee Category’, datafield: ’empcat’, width: 130 },
{ text: ‘Department’, datafield: ‘dept’, width: 115 },
{ text: ‘Job Title’, datafield: ‘jTitle’, width: 115 },
{ text: ‘Reason for Access’, datafield: ‘rAccess’, width: 135 },
{ text: ‘Line Manager’, datafield: ‘lManager’, width: 105 },
{ text: ‘Start Date’, datafield: ‘sDate’, width: 95 },
{ text: ‘End Date’, datafield: ‘eDate’, width: 95 },]
});
$(“#addrowbutton”).jqxButton({ theme: theme });
$(“#deleterowbutton”).jqxButton({ theme: theme });
$(“#updaterowbutton”).jqxButton({ theme: theme });
// update row.
$(“#updaterowbutton”).bind(‘click’, function () {
var datarow = generaterow();var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
var rowscount = $(“#jqxgrid”).jqxGrid(‘getdatainformation’).rowscount;
if (selectedrowindex >= 0 && selectedrowindex = 0 && selectedrowindex < rowscount) {
var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
$("#jqxgrid").jqxGrid('deleterow', id);
}
});
});
});<input type="hidden" id="procId" value="” name=”processId”>
Hi naveen,
Could you post the code of the generaterow function, too?
On a side note, you have an inappropriate comparison:
selectedrowindex = 0
which should be:
selectedrowindex == 0
and is actually made unnecessary by:
selectedrowindex >= 0
This, too, may be a cause of trouble.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.