EasyUI Forum
May 03, 2024, 08:49:09 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: Selecting Rows after Merging Cells....  (Read 15562 times)
2plus2
Jr. Member
**
Posts: 75


View Profile
« on: May 16, 2013, 09:49:32 AM »

Howdy...

I have a data grid where I've merged the first two cells, and have "3" rows extending from those merged cells. (see attached image)

I'm carrying extra data with each row to populate a form, so when we "edit" the row - I'm trying to iterate through the "3" rows collecting the data I want.

Code:
    function updateDlg(rowIndex) {
        for (x = rowIndex; x <= rowIndex + 2; x++) {
            $('#dgAccounts').datagrid('selectRow', x);
            var row = $('#dgAccounts').datagrid('getSelected');
            var type = row.ThresholdTypeName;

            if (row.isInitiator == 'Yes') {
                $('#' + type + 'IsInitiator').combobox('setValue', '1');
                $('#' + type + 'InitiatorDetail').slideDown();
                $('#' + type + 'InitiatorThreshold').combobox('setValue', row.InitiatorThresholdId);
            }
            if (row.isApprover == 'Yes') {
                $('#' + type + 'IsApprover').combobox('setValue', '1');
                $('#' + type + 'ApproverDetail').slideDown();
                $('#' + type + 'ApproverThreshold').combobox('setValue', row.ApproverThresholdId);
            }
            if (row.isReleaser == 'Yes') {
                $('#' + type + 'Releaser').combobox('setValue', '1');
            }
        }
    }

However, when I try to select rows "#2", and "#3", I only get the first row returned. Is there anyway to select the other two rows if the first cells are merged?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 16, 2013, 06:38:49 PM »

A more better way to get rows is calling 'getRows' method, please try code below:
Code:
var rows = $('#dgAccounts').datagrid('getRows');
for(var x = rowIndex; x<=rowIndex+2; x++){
  var row = rows[x];  // the row data
  console.log(row)
}
Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #2 on: May 16, 2013, 06:47:46 PM »

But I only want the "selected" row and it's two "siblings". Seems like a waste to grab them all, look for the selected row, and the next two that I really want.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: May 16, 2013, 07:54:31 PM »

Try code below:
Code:
var dg = $('#dgAccounts');
var selected = dg.datagrid('getSelected');  // the selected row
var rowIndex = dg.datagrid('getRowIndex', selected);  // the selected row index
var rows = dg.datagrid('getRows');
for(var x = rowIndex; x<=rowIndex+2; x++){
  var row = rows[x];  // the row data
  console.log(row)
}
Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #4 on: May 16, 2013, 08:40:36 PM »

Thanks - that's where I ended up.

Probably not "fixable" but merging the cells plays havoc with some for the datagrid methods. Hope that gets a look at to see if there are more direct ways to get the row data.
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!