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

Row navigation and deselection

4 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prabhu
Top achievements
Rank 2
Prabhu asked on 28 Jan 2009, 08:19 PM
Hi all,
   I'm using outlook type RadGrid for grouping of my records based on certain status. here I'm having couple of doubts.
       1) when I select a row through mouse, and I click the cancel linkbutton the selected row in Grid should be deselected. I tried lot of examples available in forums. but no one is working fine. May be the problem with the type of Grid that I'm using.
       2) I can navigate the records through the arrow keys. It makes me happy... but when i press Enter key on the certain row, I can handle the functionality based on selected row in server side. But here, inline form is opening. I dont want to open the form. Instead, I want to call a server side method.
    
     Hope this problem can be solved easily in Telerik controls.

    Happy coding...:)

    Thanks in advance
    Prabhu.K

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jan 2009, 05:41 AM
Hi Prabhu,

1) Try the following code snippet to cancel the row selection on clicking the cancel button in a row.

ASPX:
<telerik:GridButtonColumn Text="Cancel"  CommandName="Deselect" ButtonType="LinkButton" ></telerik:GridButtonColumn> 
                       

CS:
  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Deselect"
        { 
            e.Item.Selected = false
        }  
    } 


2) Here is the code snippet to prevent editing on pressing the 'Enter key'.

ASPX:
<ClientSettings  AllowKeyboardNavigation="true"  > 
    <ClientEvents OnKeyPress="KeyPressed" /> 
  </ClientSettings> 

JS:
 
<script type="text/javascript">  
  
 function KeyPressed(sender, eventArgs)  
{  
  if(eventArgs.get_keyCode() == 13)    
  {  
       alert('Cancel?')  
       eventArgs.set_cancel(true);     
       // to Perform PostBack 
       __doPostBack("RadGrid1");  
        
   }  
}  
</script>  

Thanks
Shinu

0
Prabhu
Top achievements
Rank 2
answered on 29 Jan 2009, 06:43 PM
Hi Shinu,

          Thanks for you reply... Since I'm not yet implement the Point (2) on my application, It seems to works well.
          For Point 1 - I forget to tell you that I'm placing the "CANCEL" Linkbutton outside the grid. I want that deselection process should be handled in w/ Post back (in JAVASCRIPT).

Thanks in advance,
Prabhu.K
0
Prabhu
Top achievements
Rank 2
answered on 29 Jan 2009, 08:39 PM
Dear Telerik team,

                Is it possible to collapse/expand the records using Arrow keys in outlook format grid? If yes, please tell me how to do that in client side?

Thanks in advance,
Prabhu.K
0
Shinu
Top achievements
Rank 2
answered on 30 Jan 2009, 06:31 AM
Hi Prabhu,

Try the following code snippet to deselect an item on the client side.

ASPX:
   <asp:LinkButton ID="LinkButton1" OnClientClick="Deselect();"  runat="server">Deselect</asp:LinkButton> 

JS:
<script type="text/javascript"
 
function Deselect() 
  var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
  //Deselect items 
  masterTable.clearSelectedItems(); 
   
</script> 



Thanks
Shinu.
Tags
Grid
Asked by
Prabhu
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Prabhu
Top achievements
Rank 2
Share this question
or