This is a migrated thread and some comments may be shown as answers.

Problem in RadGrid Multirow select

3 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zeeshan fawad
Top achievements
Rank 1
Zeeshan fawad asked on 19 Mar 2010, 06:29 AM
Hi ,
We are using RadControls_for_ASP.NET_AJAX_2010_1_309_dev in our site. In RadGrid control we are using MultiRowSelect property and also using context menue with it. If one row is selected and on other row if we right click , then second row also get selected. We want to deselect first row and select second row on right click.
May be we are trying to deselect any number of selected rows (could be 1 or more), on right click out side of that selection group. Can you please help us that how we can resolve this problem.

Regards,
Zeeshan

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Mar 2010, 11:37 AM
Hi,

Please try the js for the OnRowContextMenu client event as shown below to achieve the desired scenario:

JS:
 function RowContextMenu(sender, eventArgs) { 
            var menu = $find("<%=RadMenu1.ClientID %>"); 
            var evt = eventArgs.get_domEvent(); 
            var grid = $find("<%=RadGrid1.ClientID %>"); 
            if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") { 
                return
            } 
            var index = eventArgs.get_itemIndexHierarchical(); 
            sender.get_masterTableView().clearSelectedItems(); 
            sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 
  
            menu.show(evt); 
 
            evt.cancelBubble = true
            evt.returnValue = false
 
            if (evt.stopPropagation) { 
                evt.stopPropagation(); 
                evt.preventDefault(); 
            } 
        }  

Princy
0
Zeeshan fawad
Top achievements
Rank 1
answered on 19 Mar 2010, 01:03 PM
Hi Princy,
Thanks for response. But this solution can't solve my problem. In provided solution you are clearing all selected items in the grid on right click. We need that if Ctrl key is pressed then selected items should not be cleared. If Ctrl key is not pressed and right click on any row which was not selected with CTRL key pressed then all should be cleared else than the row where right key is pressesd.

Thnaks,
Zeeshan
0
Princy
Top achievements
Rank 2
answered on 22 Mar 2010, 08:16 AM
Hi,

From my understanding you need to unselect the other  rows only if the row that that you right clicked on is not selected using Ctrl + key .Please try cehcking if the item is selected as shown below and let me know if this is the desired result:

JS:
if (!sender.get_masterTableView().get_dataItems()[index].get_selected()) 
           { 
                sender.get_masterTableView().clearSelectedItems(); 
sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 
            } 


Princy
Tags
Grid
Asked by
Zeeshan fawad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Zeeshan fawad
Top achievements
Rank 1
Share this question
or