EasyUI Forum
May 17, 2024, 08:00:40 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: edatagrid - how can i give dynamic request parameters to the destroyUrl  (Read 6626 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« on: February 25, 2015, 02:24:25 AM »

We use edatagrid with the destroyUrl. But now we must give some dynamic request parameters to the destroyUrl.
But there is no event 'onBeforeDestroy' to change the destroyUrl before send the request to the server.

How can we give some dynamic request parameters to the destroyUrl?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 25, 2015, 10:08:58 AM »

Only the 'id' parameter can be posted to server when destroying a row. The 'id' value will be retrieved from the 'idField' field.
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #2 on: February 26, 2015, 01:14:38 AM »

OK that means we must manipulate the destroyUrl before destroy the row like this
Code:
destroyUrl: 'delete.do?secoondId=abc'
Logged
lcsft
Newbie
*
Posts: 7


View Profile
« Reply #3 on: March 02, 2015, 12:25:42 AM »

Hi,

I don't use the datagrid edit extension, so I have a special column with a delete icon on it, and I am able to use a custom function to get the selected row and pass arbitrary parameters to the server.
For the grid column:
Code:
 
{field: 'dummy_action', title: 'Manage', align:'center', width: '8%',
formatter:function(value,row,index)
{
    return '<a style="margin: 0 5px;" href="javascript:void(0)" onclick="deleteRowFunction(this, '+row.id+');"><img src="..." alt="" class="icon_del" /></a> '
}
and basics of the deleteRowFunction function
Code:
function deleteRowFunction(el, rowid)
{
    // If you need the grid, then you can query from the current element up
    var grid = jQuery(el).closest('.datagrid-wrap').find('.datagrid-f:first');
   
    // If you need you can get the row index (not row id !!) starting from where the icon is
    var tr = $(el).closest('tr.datagrid-row');
    var rowIndex = parseInt(tr.attr('datagrid-row-index'));
   
    // I use the destroyUrl (without the edatagrid.js) which you can get from the grid by
    var opts = jQuery(grid).datagrid('options');
    // and opts.destroyUrl is the param you specified at the grid init
   
    // Now get the full row from the grid
    var row = jQuery(grid).datagrid('getSelected');

    // And finally you can either append to the destroyUrl any param since you have the full row
    // Or if you have a database id in the dataset, then you don't need to query the full row, just use the rowid parameter to append it
    // to the destroyUrl, eg.
   var destroyUrl = opts.destroyUrl + '?id=' + rowid;
}

Hope this helps.
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!