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

Opening a Radwindow from RADgrid edit link(template field)

11 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gayathri
Top achievements
Rank 1
Gayathri asked on 24 Oct 2014, 11:53 AM
Hi,

I am trying to open a radwindow from radgrid edit link template field . This is done from clientclick script I mean as follows
OnClientClick="return windowopen();"  but the thing is , I have 4 records as of now. the radwindow needs to get displayed appropriately beneath each row.
I mean if it is first row , the window should get opened below that. if it is 4th row , or nth row the window should get opened beneath that.


Kindly help.


-Thanks
Gayathri

11 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Oct 2014, 11:37 AM
Hi Gayathri,

You could pass some arguments when you call the windowopen(), so you could easily access the sender element within the event handler. Once you have that element you could retrieve its position on the screen and then you could use the client-side API of the RadWindow to change its position with the set_left(...) and set_top(...) methods. Detailed information on the client-side API of RadWindow could be found in the following help article:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gayathri
Top achievements
Rank 1
answered on 05 Nov 2014, 08:35 AM
Hi Konstantin ,

Thanks for your reply. This is what I tried already. I will explain the structure of our code may be you can help us better.

There is a main.aspx and flag.aspx. I have a radgrid with template control - linkbutton in flag.aspx. in the main.aspx I have a radwindow alone which simulates the structure of the radwindow in flag.aspx. now the javascript is actually written in main.aspx to open and close the radwindow present in flag.aspx, like this RFflag.open() and close() by finidng the id of the control in main.aspx . now this script has been called by the child page flag.aspx so that everything corresponds to the main page control. and this is where the hikup is, I am able to pass the link id to the javascript Rfflag.open() but not able to set the top, left of the radwindow exactly within the nested grid which is present in flag.aspx . please note the grid is not placed in main.aspx.

I know this is little bit tough but this is how my requirement is.

Kindly help.

-Thanks
Gayathri
0
Konstantin Dikov
Telerik team
answered on 07 Nov 2014, 03:03 PM
Hi Gayathri,

As I have suggested in my previous post, you could use the DOM element of your LinkButton to retrieve the top and left position within the document and use those values when you open the window.

You could use the jQuery offset method for getting the top and left values of your LinkButton:
Since you have a rather complex scenario, I can only give you some direction for a possible implementation.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gayathri
Top achievements
Rank 1
answered on 12 Nov 2014, 04:44 AM
Thanks for the same. anyway luckily requirement got changed. now the problem is ,
I am trying to put a nestedviewtemplate inside the radgrid. this is over. when i try to click the expand collapse button, i have written the code in item command and item created. neither expand nor collapse is working. i just have only one nestedview template inside a panel .
i have attached my codebehind . please have a look and correct wherever required.
 protected void rgResponses_ItemCommand(object source, GridCommandEventArgs e)
        {

            if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item is GridDataItem)
            {

                GridDataItem Item = e.Item as GridDataItem;
                Item.Expanded = true;
                ((GridDataItem)e.Item).ChildItem.FindControl("ICexploreEval").Visible = true;
                int VerbatimId = int.Parse(Item["id"].Text);
                string sessionId = Item["SessionId"].Text;
                string url = "VerbatimExplore.aspx?SessionId=" + sessionId + "&VerbatimId=" + VerbatimId + "&ActionName=Explore";

                //TO FIND THE APPROPRIATE PAGEVIEW AND SET THE CONTENT URL - SINCE THE GRID CONTAINS THE TABSTRIP INSIDE THE PANEL, USING FIND CONTROL TO GET THE ELEMENT ID
                RadPageView ExplorePageView;
              
                foreach (GridNestedViewItem item in rgResponses.MasterTableView.GetItems(GridItemType.NestedView))
                {
                    ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");

                    ExplorePageView.ContentUrl = url;
                }
        }
}

or if you can give me an example code also will be fine. please note inside the nestedview template i have a radtabstrip followed by multipage and it is set to contenturl as you observe in the above code.

Thanks in advance. 
0
Gayathri
Top achievements
Rank 1
answered on 12 Nov 2014, 10:06 AM
Hi,

 I have set the Mastertable HierarchyLoadMode ="Client"and able to view the nestedviewtemplate at runtime which contains 2 tab pages
explore -tab1  (text on the pageview)
evaluate -tab2 
note ,: i have placed them inside the asp panel.

i need to pass content url for these tab pages through javascript becoz as i understand that setting hierarchymode=client does nt fire item command anymore. correct me if i am wrong.

    debugger;
       function OnClientTabSelecting(sender, args) {
          
            var grid = sender;
            var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
            var scell = MasterTable.getCellByColumnUniqueName(row, "SessionId");
            var vcell = MasterTable.getCellByColumnUniqueName(row, "id");

            var page = args.get_item().findControl("radExplorePgView"); // find control
            var url = "VerbatimExplore.aspx?SessionId=" + scell + "&VerbatimId=" + vcell + "&ActionName=Explore";
            page.set_contentUrl(url);  
            
        }

but it is not working. correct me if i am wrong. please help
 


0
Konstantin Dikov
Telerik team
answered on 14 Nov 2014, 12:34 PM
Hello Gayathri,

From the provided code snippet I could only assume that you are handling the OnClientTabSelecting event of the RadTabStrip, but you are using the sender as RadGrid object, which is incorrect. The sender will be the RadTabStrip object and not the RadGrid.

Additionally, when you are retrieving a cell with the getCellByColumnUniqueName, in order to get the value from the cell you should use the innerHTML property of the element and you may also need to call the trim method: cell.innerHTML.trim().

Finally, the NestedViewTemplate element must be found in the following manner:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function pageLoad() {
            var grid = $find("<%=RadGrid1.ClientID%>");
            var someItem = grid.get_masterTableView().get_dataItems()[0];
            var nestedViewTemplateRow = someItem.get_element().parentElement.rows[someItem.get_element().rowIndex];
            var radMultiPage = $telerik.findControl(nestedViewTemplateRow, "radExplorePgView");
            ///
        }
    </script>
</telerik:RadCodeBlock>


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gayathri
Top achievements
Rank 1
answered on 15 Nov 2014, 06:09 AM
Hi Konstantin ,

Thanks so much. it worked... Thanks a lot.
Now another requirement.
In the RadGrid i have two texts Explore ,evaluate. This  may be visible based on a condition 
x=1 =explore visible true,evaluate visible false. if 0 explore visible false evaluate true.
so when explore visible true the tab strip explore alone should be visible(which appears in a nestedview template)
 when evaluate is visible tab strip evaluate alone should be visible. if both of them visible false then (say x>1 ) neither tabstrip should be visible   + the expandcollapse image should also not appear.. Please help.




0
Konstantin Dikov
Telerik team
answered on 19 Nov 2014, 11:46 AM
Hi Gayathri,

I am not sure that I understand your scenario and what you want to achieve. 

Can you please provide more detailed information on the scenario and the requirement that you have, along with the markup of your page, so we can provide any assistance on this matter.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gayathri
Top achievements
Rank 1
answered on 20 Nov 2014, 06:05 AM
Hi Konstantin, 

             The requirement is , Based on the columns (explore,evaluate)condition the tabstrip should be displayed. anyways i have completed that as follows and it works great!

            if (Radgrid1.MasterTableView.GetColumn("Evaluate") != null)
            {
                if (Radgrid1.MasterTableView.GetColumn("Evaluate").Visible =  ShowAppeal)
                //if (Radgrid1.MasterTableView.GetColumn("Evaluate").Visible == false)
                {
                    foreach (GridNestedViewItem item in Radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
                    {


                        //RadPageView ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");
                        rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
                        EvaluatePgView = (RadPageView)item.FindControl("radEvalPgView");
                        rdtabexploreeval.Tabs[1].Visible = true;
                    }
                }
            }

            ////if (Radgrid1.MasterTableView.GetColumn("Explore") != null)
            ////{
            ////    if (Radgrid1.MasterTableView.GetColumn("Explore").Visible == Showexplore)
            ////    {
            ////        foreach (GridNestedViewItem item in Radgrid1.MasterTableView.GetItems(GridItemType.NestedView))
            ////        {


            ////            //RadPageView ExplorePageView = (RadPageView)item.FindControl("radExplorePgView");
            ////            rdtabexploreeval = (RadTabStrip)item.FindControl("rdtabexploreeval");
            ////            ExplorePgView = (RadPageView)item.FindControl("radExplorePgView");
            ////            rdtabexploreeval.Tabs[0].Visible = false;
            ////        }
            ////    }
            ////}
            if ((Radgrid1.MasterTableView.GetColumn("Explore").Visible == ShowAppeal) && (Radgrid1.MasterTableView.GetColumn("Evaluate").Visible == ShowAppeal))
                 {
                              
                     Radgrid1.MasterTableView.ExpandCollapseColumn.Visible = false;
                 }
         
        

        }

0
Gayathri
Top achievements
Rank 1
answered on 20 Nov 2014, 06:30 AM
Hi,

I have one more query, the above code is written in Itemcreated. Actually there are some conditions check in RADgrid1_prerender. What is the difference between radgrid1_itemcreated and radgrid1_prerender.

If i move the code to Prerender ? what will be the behavioural change?

-Thanks

gayathri
0
Konstantin Dikov
Telerik team
answered on 24 Nov 2014, 12:33 PM
Hi Gayathri,

RadGrid, as all the other controls from our suite, are following the same conventions for the server-side events as the standard ASP.NET server controls.

The ItemCreated event of the grid will fire right after an item is created and the PreRender event will fire just before the rendering of the  RadGrid. The ItemCreated event will fire multiple times - for each item (GridHeaderItem, GridFooterItem, GridDataItem, etc.) and the PreRender event will fire only once.

In the following help article you can find the event sequence in RadGrid:
As for your scenario, the PreRender event should be more appropriate, because it will fire only once and you should still be able to set the visibility of RadTabStrip.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Gayathri
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Gayathri
Top achievements
Rank 1
Share this question
or