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

Switch tabs when a Row is double clicked

5 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ali Kitabi
Top achievements
Rank 1
Ali Kitabi asked on 06 Mar 2009, 12:02 AM
Hi,

I have a RadGrid under a RadTabStrip. ALL controls on the page are created dynamically. I need that when a Row in the Grid is double clicked, the client side javascript function switches the Tab according to a cell value on the Row. I have reached to the point where I can get my desired value from the Row. I get stuck when I need to reference the RadTabStrip that is being generated dynamically.



<head runat="server">  
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
    <script type="text/javascript">  
         <!--  
        function OnRowDblClick(sender, eventArgs) {  
            var dataItem = $get(eventArgs.get_id());  
            var grid = sender;  
            var MasterTable = grid.get_masterTableView();  
            var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];  
            var cell = MasterTable.getCellByColumnUniqueName(row, "CurrRegionName");  
            alert(cell.innerHTML);  
            var tabStrip = $find("<%= TabStrip1.ClientID %>");  
            var selectedTab = tabStrip.findTabByText(cell.innerHTML);  
            tabStrip.commitChanges();  
        }  
            -->  
    </script>  
    </telerik:RadCodeBlock>  
    <title></title> 

I get this error

Server Error in '/' Application.  
--------------------------------------------------------------------------------  
 
Compilation Error   
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.   
 
Compiler Error Message: CS0103: The name 'TabStrip1' does not exist in the current context  
 
Source Error:  
 
   
 
Line 15:             var cell = MasterTable.getCellByColumnUniqueName(row, "CurrRegionName");  
Line 16:             alert(cell.innerHTML);  
Line 17:             var tabStrip = $find("<%= TabStrip1.ClientID %>");  
Line 18:             var selectedTab = tabStrip.findTabByText(cell.innerHTML);  
Line 19:             tabStrip.commitChanges();  
   
 
Source File: c:\AIK\Projects\Web\I2Care\AssetMgmt\ShowTabs.aspx    Line: 17  

Any help would be appreciated.

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Mar 2009, 08:37 AM
Hello Ali,

One possible option in this case would be to get a reference to the client side object of a given tab, and use the select/unselect client side methods to take action. Additional information on this option is available in the following article. I hope this gets you started properly.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ali Kitabi
Top achievements
Rank 1
answered on 10 Mar 2009, 08:17 PM
Hi Yavor,

The article you referred also only applies any property or method if the client-side can find that Tab. Now the problem here is that the JS cannot find the TabStrip at complie time therefore giving that error. Is there any way that we can find which tabstrip contains the gridrow that has been double clicked?
0
Yavor
Telerik team
answered on 13 Mar 2009, 11:09 AM
Hello Ali,

Please, keep in mind that if the tab cannot be located like this, it may be because it is nested in another naming container. Therefore, you can try to locate it via its client Id. If this is not possible either, you can move the logic to the server - make an AjaxRequest once you have double-clicked on  a row, and from the server - set the desired tab.

All the best,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ali Kitabi
Top achievements
Rank 1
answered on 13 Mar 2009, 03:28 PM
Hi Yavor,

The Tab is in the Form container only.

myRadTabStrip.TabClick += new RadTabStripEventHandler(myRadTabStrip_TabClick);  
this.Page.Form.Controls.Add(myRadTabStrip);  
this.Page.Form.Controls.Add(myRadMultiPage); 

However, you mentioned to make an AjaxRequest once you have double-clicked on  a row, and from the server and set the desired tab. Can you help me with this by providing a small example.

It would be appreciated.

Regards,

Ali
0
Yavor
Telerik team
answered on 16 Mar 2009, 11:19 AM
Hi Ali,

The following article contains more information on how to make an ajaxRequest to the server. Once you intercept the request on the server, you can easily change the selected tab.
I hope this helps.

Best wishes,
Yavor
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Ali Kitabi
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Ali Kitabi
Top achievements
Rank 1
Share this question
or