EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: andrux on May 08, 2013, 06:36:53 AM



Title: Get datagrid row from inside another datagrid embeded in a dialog box
Post by: andrux on May 08, 2013, 06:36:53 AM
Hello, all.

I have a datagrid that works great, then when I click the EDIT button I open up a dialog box where I put another datagrid with some properties for the selected row, when I hit the SAVE button I want to know which row I was editing but it looks like I have no access to it.

Here's how I initialize my datagrid:

Code:
$( '#my-second-dg' ).edatagrid({
title: 'Role Permissions',
url: 'get_items_list.php&id=' + paramId,
...... // more parameters here
});

So, I set paramId with the row id from my main datagrid, but when I initialize my second datagrid paramId is empty.

Anybody knows how can I achieve that?


Title: Re: Get datagrid row from inside another datagrid embeded in a dialog box
Post by: andrux on May 08, 2013, 08:56:17 AM
Ok, I finally got it working.

What I did was just to grab the selected row before calling edatagrid() and setup my url variable, if there wasn't a selected row then just use a dummy string, like so:

Code:
var paramId = ( $( '#my-first-dg' ).datagrid( 'getSelected' ) === null ) ? '0' : $( '#my-first-dg' ).datagrid( 'getSelected' ).id;

$( '#my-second-dg' ).edatagrid({
title: 'Role Permissions',
url: 'get_items_list.php&id=' + paramId,
...... // more parameters here
});

Took quite some time to figure it out but that's the way I was able to fix my issue.

Thanks for reading everyone