RadGrid inside a RadWindow, issue with NavigateURL

9 posts, 1 answers
  1. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 12 Aug 2015 Link to this post

    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);
              
            }
                 ​

  2. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 17 Aug 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 17 Aug 2015 in reply to Eyup Link to this post

    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;         
              
            }

  5. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1494 posts

    Posted 20 Aug 2015 Link to this post

    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
  6. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 20 Aug 2015 in reply to Danail Vasilev Link to this post

    Thank you
  7. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 20 Aug 2015 in reply to binny Link to this post

    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 ?
  8. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 25 Aug 2015 Link to this post

    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
  9. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 25 Aug 2015 in reply to Eyup Link to this post

    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");
              }​

  10. binny
    binny avatar
    21 posts
    Member since:
    Jan 2015

    Posted 25 Aug 2015 in reply to binny Link to this post

    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 

     

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017