EasyUI Forum
April 29, 2024, 12:12:22 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: How to prevent multiple selection in multiple subgrids?  (Read 893 times)
aerdem
Newbie
*
Posts: 5


View Profile Email
« on: October 27, 2022, 05:12:25 AM »

We are using EasyUI for JQuery.
In one of the pages I used datagrid and subgrid. (similar to this sample:https://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=material-teal&dir=ltr&pitem=&sort=asc)

When user opens more than one items in the main datagrid, user can select multiple items in different subgrids. The same case occurs in the demo. (You can see on the attachment.)

 I can access the selected item in the subgrid that is under the selected item in the main datagrid. But I can not access the selected items in subgrids under unselected items in the main datagrid.

The selection of multiple items in different subgrids leads to confusion for users when performing operations.

I want to ask whether there is a way of
1 preventing selection in subgrids which are under the unselected item of the main datagrid.
2 selecting item in the main grid when item is subgrid is selected.

I hope I could describe the situation and my expectation.

Best regards

« Last Edit: October 27, 2022, 05:14:53 AM by aerdem » Logged
aerdem
Newbie
*
Posts: 5


View Profile Email
« Reply #1 on: October 27, 2022, 10:15:57 AM »

I solved the problem by collapsing the previously expanded row in the main datagrid.

I hold the index of the previously selected row. Then in each expansion of a row, I collapse the previously expanded row.
In this way, only one row is expanded in the master datagrid and this prevents confusion.

This is my code
Code:
 
  var selectedIndex=-1;
   .....................................
  onExpandRow: function (index, row) {

     //collapse previously expanded parent row.
     if (selectedIndex>-1 && selectedIndex!=index)
             $(this).datagrid('collapseRow',selectedIndex);
    
      selectedIndex=index;
      ..................
  }

I am also open to other solutions.
« Last Edit: October 27, 2022, 10:17:39 AM by aerdem » 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!