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

RadGrid inside a RadWindow, issue with NavigateURL

8 Answers 50 Views
Window
This is a migrated thread and some comments may be shown as answers.
binny
Top achievements
Rank 1
binny asked on 12 Aug 2015, 10:49 PM

This is a simple issue but not sure what I am doing wrong , this piece of code opens a radwindow but doesnt hit the details.aspx

 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>           
    </telerik:RadAjaxManager>

       <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2010Silver" AllowPaging="True" AllowSorting="True" AllowFilteringByColumn="True" PageSize="25" OnItemCommand="RadGrid1_ItemCommand">
         <PagerStyle Mode="NumericPages" AlwaysVisible="true"></PagerStyle>
         <MasterTableView >

      <Columns>
        <telerik:GridTemplateColumn UniqueName="TemplateColumn">
            <ItemTemplate>                
                <span> <asp:ImageButton ID="NotifyAgain" ImageUrl="~/Images/details.png"  CommandName="details" runat = "server" /> </span>              
                            
            </ItemTemplate>
        </telerik:GridTemplateColumn>
      </Columns>
    </MasterTableView>
         <HeaderStyle Width="10px" />
         <ClientSettings EnableRowHoverStyle="true">
              <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" AllowResizeToFit="true" />
            </ClientSettings>
     </telerik:RadGrid>

        
        <telerik:RadWindow ID="RadWindow1" Modal="true"  Skin="MetroTouch" runat="server" Width="800px" Height="800px" Title="Details" CssClass="override" >
  
</telerik:RadWindow>

  protected void Page_Load(object sender, EventArgs e)
              
        {       
            if (!Page.IsPostBack)
            {
                RadGrid1.DataSource = GetDataTable();
                RadGrid1.DataBind();

            }
        }


  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            GridDataItem item = (GridDataItem)e.Item;
            string value = item["FileName"].Text;

            switch (e.CommandName)
            {
                case "details": Details(value);
                    break;
            }
        }

        private void Details(string fileName)
        {

            string fullPath = ConfigurationManager.AppSettings["path"] + fileName;     

             RadWindow1.NavigateUrl = "details.aspx?name=" + fileName; 

             string script = "function f(){$find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
          
        }
             ​

8 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 17 Aug 2015, 12:22 PM
Hi Binny,

The NeedDataSource event is the mandatory way when you need to bind the grid to a programmatic data source in the code-behind. It is important to note that you are not using DataBind() to bind the grid. Performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
Declarative DataSource
Programmatic Data Binding


Hope this helps. Please make the suggested modification and let me know about the result.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
binny
Top achievements
Rank 1
answered on 17 Aug 2015, 04:12 PM

Hello Eyup,

Thank you, I made that change but still it doesnt work 

 I am having this weird issue with Radwindows navigateurl property 

When I do something like this it redirects

 <telerik:RadWindow ID="Details" Modal="true" Skin="MetroTouch" runat="server" Width="800px" Height="800px" Title="Details" CssClass="override" NavigateUrl="~/Details.aspx'" ></telerik:RadWindow>

But when I do it through the code behind it doesnt redirect to that page 

  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                string value = item["Name"].Text;

                switch (e.CommandName)
                {
                    case "download": download(value);
                        break;
                    case "details": Details(value);
                        break;
                    case "sendemail": sendemail(value);
                        break;
                }
            }
        }

 private void Details(string Name)
        {            
            
            string script = "function f(){$find(\"" + Details.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            string url = "details.aspx?name=" + Name;
            Details.NavigateUrl = url;         
          
        }

0
Accepted
Danail Vasilev
Telerik team
answered on 20 Aug 2015, 01:40 PM
Hello Binny,

It seems that this event is triggered too late for setting the property of the window. What I can suggest is that you set the navigateUrl on the client-side as well:

private void Details(string fileName)
{
 
    string fullPath = "http://www.bing.com";//ConfigurationManager.AppSettings["path"] + fileName;
 
    RadWindow1.NavigateUrl = fullPath;// "details.aspx?name=" + ;
 
    string script = "function f(){$find(\"" + RadWindow1.ClientID + "\").set_navigateUrl((\"" + fullPath + "\")); $find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
 
}


Regards,
Danail Vasilev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
binny
Top achievements
Rank 1
answered on 20 Aug 2015, 02:20 PM
Thank you
0
binny
Top achievements
Rank 1
answered on 20 Aug 2015, 02:38 PM
One thing I noticed here that it keeps the value of filename same for all the rows , is there a way to get around that ?
0
Eyup
Telerik team
answered on 25 Aug 2015, 07:13 AM
Hello Binny,

Could you check whether the correct fileName is passed as argument when you are calling the Details method? If not, then you can try to set CommandArgument of the ImageButton:
<asp:ImageButton ... CommandArgument='<%# Eval("ShipName") %>' />
C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == "details")
    {
        string name = e.CommandArgument.ToString();
    }
}

That should do the trick. Looking forward to your reply.

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
binny
Top achievements
Rank 1
answered on 25 Aug 2015, 06:11 PM

I am getting the correct filename using this code snippet , just that the navigateURL is not being updated even though I see at  server side that it has been updated but when the Radwindow loads the first same file name all the time and then I thought it was getting cached so I tried DestroyOnClose ="true", it didnt work 

 

 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
               string value = item["FileName"].Text;
             
                switch (e.CommandName)
                {
                    case "download": download(value);
                        break;
                    case "details": Details(value);
                        break;
                    case "sendemail": sendemail(value);
                        break;
                }
            }
        }

 

So I now I am dojng it client side and now it is working but not the way I wanted 

 

 function RowSelected(sender, args) {
              var filename = args.getDataKeyValue("FileName");
              var wnd = $find("<%=RadWindow1.ClientID %>");
              wnd.setUrl('meetingdetails.aspx?meetingname=' + filename);
              wnd.show();

              //window.radopen('meetingdetails.aspx?meetingname=' + filename, "RadWindow1");
          }​

0
binny
Top achievements
Rank 1
answered on 25 Aug 2015, 08:24 PM

Ok I know what I am doing wrong , I should be using Radwindow's  ReloadOnShow and set it to "true", that fixed this issue 

Thank you for pointing me in the right direction 

 

 

Tags
Window
Asked by
binny
Top achievements
Rank 1
Answers by
Eyup
Telerik team
binny
Top achievements
Rank 1
Danail Vasilev
Telerik team
Share this question
or