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

How to disable AllowRowSelect in DetailTable?

5 Answers 396 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 22 Apr 2010, 03:39 PM
2009.3.1210.35



DetailTables does not have ClientSettings.
In Master table I have these two defined to true but I want them false in the Detail Table.

Selecting-AllowRowSelect="false" EnableRowHoverStyle="false"

Please advise, thanks.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Apr 2010, 06:24 AM
Hello Lenny,

You can disallow row selection for the detailtable by adding following code in RowSelecting event. Hope the following example will help you.

ASPX:

 
        <telerik:RadGrid ID="RadGrid1" TabIndex="1" ShowGroupPanel="True" AllowMultiRowSelection="true"  
            ShowStatusBar="true" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False">  
            <MasterTableView TableLayout="Fixed" AllowMultiColumnSorting="True" CommandItemDisplay="Top"  
                DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" Width="100%" Name="Master" >  
                <DetailTables>  
                    <telerik:GridTableView Caption="Detail Table" DataKeyNames="OrderID" NoDetailRecordsText=""  
                        Name="Detail" DataSourceID="SqlDataSource2" CommandItemDisplay="Top" Width="100%"  
                        runat="server">  
                        <ParentTableRelation>  
                            <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />  
                        </ParentTableRelation>                      
                        <Columns>  
                          . . .  
                        </Columns>                      
                    </telerik:GridTableView>  
                </DetailTables>              
                <Columns>  
                  . . .  
                </Columns>                
            </MasterTableView>  
            <ClientSettings>  
                <Selecting AllowRowSelect="true" />  
                <ClientEvents RowSelecting="RowSelecting" />  
            </ClientSettings>  
     </telerik:RadGrid> 

JavaScript:

<script type="text/javascript"
    function RowSelecting(sender, args) { 
        if (args.get_tableView().get_name() != "Master") { 
            args.set_cancel(true); 
            alert("Cannot Select"); 
        } 
    } 
</script> 

Regards,
Shinu.
0
Lenny_shp
Top achievements
Rank 2
answered on 23 Apr 2010, 10:33 PM
2009.3.1210.35
RowSelecting
works for you without the On prefix?

<ClientEvents RowSelecting="RowSelecting" /> 

Similiar issue here, what's the way to disable RowHover in detail table?
EnableRowHoverStyle="true"
0
Shinu
Top achievements
Rank 2
answered on 26 Apr 2010, 09:15 AM
Hi Lenny,

 RowSelecting ClietEvent in ClientSettings won't work without On Prefix. That was a mistake happened while I copied the code.
 <ClientEvents OnRowSelecting="RowSelecting" /> 

 Checkout the following example for disabling RowHover for detail table. You could attach the client events in the  'ClientSettings->ClientEvents' section of the grid markup as shown below:
 
ASPX:
          
             <
ClientSettings EnableRowHoverStyle="true"
                    <ClientEvents OnRowMouseOver="RowMouseOver" /> 
            </ClientSettings> 

Here is the client code for setting the style in  'OnRowMouseOver'.

Javascript:
 
function
 RowMouseOver(sender, eventArgs) { 
        // 'Order' is the DetailTable name 
        if (eventArgs.get_tableView().get_name() == "Order") { 
            var className = $get(eventArgs.get_id()).className
             
            //Checking for row type 
            if (className.match("Alt")) // Alternative Row 
                $get(eventArgs.get_id()).className = "MyAltClass"
            else 
                $get(eventArgs.get_id()).className = "MyClass"
        } 
    } 

CSS:
 
<style type=
"text/css"
      
        .MyClass 
        { 
            padding-left7px !important; 
            padding-right7px !important; 
            border-stylesolid !important; 
            border-width: 0 !important; 
            border-bottom-width1px !important; 
            padding-top4px !important; 
            padding-bottom3px !important; 
            border#f7f7f7 !important; 
            background#f7f7f7 !importan 
        } 
        .MyAltClass 
        { 
            padding-left7px !important; 
            padding-right7px !important; 
            border-stylesolid !important; 
            border-width: 0 !important; 
            border-bottom-width1px !important; 
            padding-top4px !important; 
            padding-bottom3px !important; 
            border#f2f2f2 !important; 
            background#f2f2f2 !important; 
        } 
</style> 

Regards
Shinu.
0
SWAT
Top achievements
Rank 2
answered on 10 Oct 2012, 04:16 AM
Hello, first i want to say that i was not interested in the hover issue, only in the click. 
so, i've used the suggested solution and although it works it is not perfect.
the problem is that even if the row in the detailed grid does not get selected- it de-select any selected row in the master grid!

is there anyway to prevent it? 

Thanks,
ilan.
0
Eyup
Telerik team
answered on 12 Oct 2012, 11:53 AM
Hi Ilan,

Could you please try the following approach/?
<ClientEvents OnRowSelecting="rowSelecting" OnRowDeselecting="rowDeselecting" OnRowClick="rowClicked" />
  JavaScript:
var isDetail = false;
function rowClicked(sender, args) {
    if (args.get_tableView().get_name() != "Master") {
        isDetail = true;
    }
}
function rowDeselecting(sender, args) {
    if (isDetail) {
        args.set_cancel(true);
        isDetail = false;
    }
}
function rowSelecting(sender, args) {
    if (isDetail) {
        args.set_cancel(true);
    }
}

I hope this will prove helpful. Please give it a try and let me know about the result.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Lenny_shp
Top achievements
Rank 2
SWAT
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or