10 Ocak 2013 Perşembe

RadGrid: to deselect the last selected item on client side

In order to deselect the last selected item in the RadGrid, the following function can be used on client side:
javascript:
 <telerik:RadCodeBlock ID="RadCodeBlock" runat="server">  
     <script type="text/javascript">  
       function DeselectLastSelected(gridID, index) {  
         var masterTable = $find(gridID).get_masterTableView();  
         masterTable.deselectItem(masterTable.get_selectedItems()[index].get_element());  
       }  
        function RowSelected(sender, eventArgs) {  
         if (sender != null) {  
           var numOfSelected = sender.get_masterTableView().get_selectedItems().length;  
           DeselectLastSelected(sender.ClientID, numOfSelected - 1);  
         }  
       }  
  </script>  
   </telerik:RadCodeBlock>  
RadGrid:
 telerik:RadGrid AutoGenerateColumns="False" ID="GridOgrenciDersListe" AllowFilteringByColumn="false"   
    AllowPaging="False" AllowSorting="False" runat="server" ShowGroupPanel="false"   
    Width="560px" AllowMultiRowSelection="True" ShowFooter="false" Visible="false">   
    <PagerStyle Mode="NextPrevAndNumeric" />   
    <GroupingSettings CaseSensitive="false" />   
    <ClientSettings EnableRowHoverStyle="true">   
     <Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true"></Selecting>   
     <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />   
    </ClientSettings>   
    <MasterTableView TableLayout="Fixed" DataKeyNames="ID" Font-Size="XX-Small" ClientDataKeyNames="ID">   
     <Columns>   
      <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">   
      </telerik:GridClientSelectColumn>   
  </Columns>   
    </MasterTableView>   
   </telerik:RadGrid>   

Hiç yorum yok:

Yorum Gönder