jQuery UI Widgets Forums Grid Selectedrowindex is -1 and id is undefined


This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 8 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • dujmovicv

    Hi All,

    I’m trying to get the delete row function work…
    Here’s the part of the code :
    // delete row.

    $("#deleterowbutton").bind('click', function () {
    	var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex');
    	var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
    	if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    		var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
    		$("#jqxgrid").jqxGrid('deleterow', id);

    looking at the console log : ‘selectedrowindex’ is always -1 and ‘id’ is : undefined which of course results that the delete function is not working…
    Here’s the deleterow function :

    id: 'RecordID',
    deleterow: function (rowid, commit) {
    	// synchronize with the server - send delete command
    	   var data = "delete=true&" + $.param({RecordID: rowid});
    			dataType: 'json',
    			url: '../jqw/data.php',
    			cache: false,
    			data: data,
    			success: function (data, status, xhr) {
    			   // delete command is executed.
    			error: function(jqXHR, textStatus, errorThrown)

    What am I doing wrong here? Thanks in advance.

    Peter Stoev

    Hi dujmovicv,

    It’s -1 when a row is not selected. If you don’t use row selection or you use row selection and no row is selected, it will always be -1. id is undefined because you pass -1 to getrowid. When you pass invalid params, the function will return undefined or null.

    Best Regards,
    Peter Stoev

    jQWidgets Team

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.