EasyUI Forum
May 19, 2024, 04:30:37 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: destroyUrl not firing  (Read 10509 times)
andrux
Newbie
*
Posts: 26


View Profile
« on: May 09, 2013, 02:47:18 PM »

Hello again.

I'm trying to get my datagrid to update and delete records from the database, but I run into the problem that the destroyUrl property is not working. I haven't put all logic inside my destroy.php file to actually delete a record, I wanted to try something simple before that, just update a record in the database with 'test delete succeeded', so that I rule out everything else.

The updateUrl correctly updates the database with 'test update succeeded', but the destroyUrl is not doing anything.

I have my datagrid initialized like this:

Code:
	jQuery( document ).ready( function ( $ ) {
$( '#dg' ).edatagrid({
url: 'get.php',
updateUrl: 'update.php',
destroyUrl: 'destroy.php',
title: 'my datagrid',
width: 'auto',
height: '400',
pagination: true,
singleSelect: true,
idField: 'option_id',
fitColumns: true,
rownumbers: true,
sortName: 'option_id',
sortOrder: 'asc',
pageSize: 10,
pageList: [ 10, 20, 30 ],
columns: columnsArray,
onBeforeEdit: function( index, row ) {
row.editing = true;
updateActions( index );
},
onAfterEdit: function( index, row ) {
row.editing = false;
updateActions( index );
},
onCancelEdit: function( index, row ) {
row.editing = false;
updateActions( index );
}
});
});

function updateActions( index ) {
jQuery( '#dg' ).datagrid( 'updateRow', {
index: index,
row: {}
});
}

function getRowIndex( target ) {
var tr = jQuery( target ).closest( 'tr.datagrid-row' );
return parseInt( tr.attr( 'datagrid-row-index' ) );
}

function editrow( target ) {
jQuery( '#dg' ).datagrid( 'beginEdit', getRowIndex( target ) );
}

function deleterow( target ) {
jQuery.messager.confirm( 'Confirm', 'Are you sure you want to delete this record?', function( r ) {
if ( r ){
jQuery( '#dg' ).datagrid( 'deleteRow', getRowIndex( target ) );
}
});
}

function saverow( target ) {
jQuery( '#dg' ).datagrid( 'endEdit', getRowIndex( target ) )
}

function cancelrow( target ) {
jQuery( '#dg' ).datagrid( 'cancelEdit', getRowIndex( target ) );
}


Am I missing something here?

Thank you in advance for your help.
Logged
joe
Newbie
*
Posts: 33


View Profile Email
« Reply #1 on: May 09, 2013, 10:31:06 PM »

    $( '#dg' ).edatagrid( 'destroyRow');
Logged
andrux
Newbie
*
Posts: 26


View Profile
« Reply #2 on: May 10, 2013, 10:18:40 AM »

Thanks, Joe, but it didn't work.

What I ended up doing is modifying the deleterow function like this:

Code:
	function deleterow( target ) {
$.messager.confirm( 'Confirm', 'Are you sure you want to delete this record?', function( r ) {
if ( r ) {
var data = {};
data.rows = $( '#dg' ).datagrid( 'getRows' )[ getRowIndex( target ) ];

$.post( 'destroy.php', data, function( response ) {
if ( response == 'success' )
$( '#dg' ).datagrid( 'deleteRow', getRowIndex( target ) );
});
}
});
}

Thank you all
Logged
joe
Newbie
*
Posts: 33


View Profile Email
« Reply #3 on: May 10, 2013, 10:29:02 AM »

your original code uses "edatagrid" and not "datagrid".  Note the difference.
Logged
andrux
Newbie
*
Posts: 26


View Profile
« Reply #4 on: May 10, 2013, 10:31:27 AM »

Yes, I see the difference, but it's working like this so I'll just leave it like that.

Thank you
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!