Telerik
Skip Navigation LinksHome / Community / Forums / ASP.NET AJAX > Grid > Identifying the Grid

Not answered Identifying the Grid

Feed from this thread
  • Asra avatar

    Posted on Jun 13, 2009 (permalink)

    Hi All,
                 Iam using two levels of hireachy in the Grid. The main Grid is RadGrid and SubGrid is RadGrid. Inside this SubGrid I have one more RadGrid. On the ItemCommand event how to identify the Grid

    Can any one pls let me know.

    Its very Urgent.

    Regards
    asra

    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 14, 2009 (permalink)

    Hello Asra,

    I'm not sure if I understand your scenario completely. If you have multiple (nested) RadGrids and they share the same ItemCommand handler, you may try the following approach:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        string ownerGrid = e.Item.OwnerGridID; 

    Kind regards,
    Daniel
    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.

    Reply

  • Asra avatar

    Posted on Jun 14, 2009 (permalink)

    Hi,
    Thnx for your reply.

    Iam just trying to replicate the demo HireachyTemplate of RadGrid. On the top of the Grid i have a button. On the click of this button i should be able to expand the Grid. Iam not able to find the InnerRadGrid on the Click of button.
    For this iam writing like
    RadGrid rgd=(RadGrid)RadGrid1.MasterTableView.FindControl("InnerGrid");
    but the above code is not able to find the Grid.

    One more button is there, on the click of that button a column of the grid should be visible true or false. This Iam handling in JavaScript. But iam not able to find the Id of the Inner Grid.
    Can you pls let me know how to find the id of the InnerGrid using JavaScript. and aslo how to find the InnerGrid on the click of button.



    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 18, 2009 (permalink)

    Hello Asra,

    You can test my suggestion on the Hierarchy with Templates demo.

    Server-side:
    protected void Button1_Click(object sender, EventArgs e) 
        foreach (GridNestedViewItem item in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)) 
        { 
            RadGrid ordersGrid = item.FindControl("OrdersGrid"as RadGrid; 
            if (ordersGrid != null
                ;//do something 
        } 

    Client-side:
    <script type="text/javascript"
        function findNestedGrid() 
        {  
            var outerGrid = $find('<%= RadGrid1.ClientID %>'); 
            var dataItems = outerGrid.get_masterTableView().get_dataItems(); 
            for (var item = 0; item < dataItems.length; item++) 
            { 
                var nextSibling = dataItems[item].get_element().nextSibling; 
                if (!nextSibling)  continue
                var nestedGrid = $telerik.findControl(nextSibling, "OrdersGrid"); 
                if(nestedGrid)  alert(nestedGrid.get_id()); 
            } 
        } 
    </script> 

    Best regards,
    Daniel
    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.

    Reply

  • Asra avatar

    Posted on Jun 18, 2009 (permalink)

    Hi Daniel,

    Thanks for providing the code to access the inner grid.
    We used the code, which as been provide by you to hide the columns of Inner Grid, as shown below ..
    nestedGrid.get_masterTableView().showColumn(4);  But we are unable to show column 4 of the inner grid.
    Could you please, help us in resolving this issue.

    We are current blogged with this, So could you please provide the solution ASAP.

    Thanks & Regards,
    ASRA
    function findNestedGrid()    
        {     
            var outerGrid = $find('<%= RadGrid1.ClientID %>');    
            var dataItems = outerGrid.get_masterTableView().get_dataItems();    
            for (var item = 0; item < dataItems.length; item++)    
            {    
                var nextSibling = dataItems[item].get_element().nextSibling;    
                if (!nextSibling)  continue;    
                var nestedGrid = $telerik.findControl(nextSibling, "OrdersGrid");    
                if(nestedGrid)   
                {                
                nestedGrid.get_masterTableView().showColumn(4);   //We are not able to show column 4                       
                }                 
            }    
        }    
     
     

    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 22, 2009 (permalink)

    Hello Asra,

    I suppose you provided wrong column index to the showColumn method. Please note that in this case the fourth column is GridCalculatedColumn (Order Total).
        <telerik:GridCalculatedColumn UniqueName="Total" DataFields="Total" Expression="{0}" 
            HeaderText="Order Total" DataType="System.Double" DataFormatString="{0:C}" Display="false"
        </telerik:GridCalculatedColumn> 
    </Columns> 

        if (nestedGrid) 
        { 
            nestedGrid.get_masterTableView().showColumn(4); 
        } 

    Hope this helps

    Regards,
    Daniel
    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.

    Reply

  • Asra avatar

    Posted on Jun 22, 2009 (permalink)

    Hi Daniel,

    Firstly let me thankyou for your reply.
    But my grid column is not GridCalcaultedColumn. Its a bound column only.
    nestedGrid.get_masterTableView().showColumn(4), when iam uisng this showcolumn it is givng me error as Undefined Column.
    even if i give the column index as 1, it is giving me error.

    Can you pls help me out . This is only issue for which i got blocked.
    Reqeust you respond ASAP.

    Regards,

    asra

    Reply

  • Telerik Admin admin's avatar

    Posted on Jun 22, 2009 (permalink)

    Hello Asra,

    I noticed that you have opened a support ticket related to the same subject. Please attach a runnable version of your project (preferably a stripped one) and I will modify the code for you.

    Regards,
    Daniel
    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / ASP.NET AJAX > Grid > Identifying the Grid
Related resourses for "Identifying the Grid"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.