Window as dialog-Return value in Radgrid Edit form template

28 posts, 1 answers
  1. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 01 Jun 2009 Link to this post

    Hi there ,
    Is it possible to return the value from my radwindow to the edit form of a radgrid (radtextbox)?
    (line 27)

     

    1   function ShowDialog() {  
    2            //window.radopen(null, "DialogWindow");  
    3  
    4            //Forced reload (option 1): In order to force a reload on the dialog, the following approach should be used  
    5            //window.radopen("./SimpleDialog.aspx", "DialogWindow");  
    6  
    7            //Forced reload (option 2): If one is not sure what the current url is, forced reload can be achieved like this:  
    8            var oWnd = window.radopen(null"DialogWindow");  
    9            oWnd.SetUrl(oWnd.GetUrl());  
    10        }  
    11  
    12        /* Called when a window is being shown. Good for setting an argument to the window */ 
    13        function OnClientShow(radWindow) {  
    14            //Get current content of textarea  
    15            var oText = document.getElementById("<%=radtextbox1.ClientID %>").value;  
    16  
    17            //Create a new Object to be used as an argument to the radWindow  
    18            var arg = new Object();  
    19            //Using an Object as a argument is convenient as it allows setting many properties.  
    20            arg.TextValue = oText;  
    21            //Set the argument object to the radWindow         
    22            radWindow.Argument = arg;  
    23        }  
    24  
    25  
    26        function CallBackFunction(radWindow, returnValue) {  
    27            var oArea = document.getElementById("<%=ChequeDetailsGrid.ClientID %>");  
    28            if (returnValue) oArea.value = returnValue;  
    29            else alert("No text was returned");  
    30        }  
    31  
    32        /* Called when a window is being closed. */ 
    33        function OnClientClose(radWindow) {  
    34            //Another option for passing a callback value  
    35            //Set the radWindow.Argument property in the dialog  
    36            //And read it here --> var oValue = radWindow.Argument;  
    37  
    38            //Do cleanup if necessary  
    39        }     

    Thanxs in advance
    Panos

  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 01 Jun 2009 Link to this post

    Hi Panayiotis,

    I believe that this and this online demos will be of help.

    Sincerely yours,
    Fiko
    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.
  3. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 01 Jun 2009 Link to this post

    Thanxs for the reply

    I was able to return the value in a textbox in my form. But what i want to do is to return the value in the Radgrid inside a radtextbox while i am inside the edit form template. So how should i change the geteelementbyId in order to save the returned value from by dialog.aspx page to a the radtextbox inside the edit  form template?  

     


    function
    CallBackFunction(radWindow, returnValue) {

     

     

    var oArea = document.getElementById("<%=textbox1.ClientID %>");

     

     

    if (returnValue) oArea.value = returnValue;

     

     

    else alert("No text was returned");

     

    }


    Regards
  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 02 Jun 2009 Link to this post

    Hello Panayiotis,

    You can try handling the OnLoad client-side event of RadTextBox and get the instance of the RadTextBox object there. Then you could use it in the RadWindow callback function.

    <script type="text/javascript">  
    var textBox = null;  
    function Load(sender, eventArgs)  
       {  
           textBox = sender;  
       }  
    </script> 
     
    <telerik:RadGrid ID="RadGrid1" runat="server">  
       <MasterTableView> 
            <Columns> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
                    <EditItemTemplate> 
                        <telerik:RadTextBox ID="RadTextBox1" runat="server">  
                            <ClientEvents OnLoad="Load" />    
                        </telerik:RadTextBox> 
                    </EditItemTemplate> 
               </telerik:GridTemplateColumn> 
           </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 


    Greetings,
    Iana
    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.
  5. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 02 Jun 2009 Link to this post

    I fillowed your instrunctions but i am getting some javascript errors.

    What should i include in the quotes?

    var oText = document.getElementById(").value;

    Thanxs

     

  6. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 03 Jun 2009 Link to this post

    Hello Panayiotis,

    In the sample  code I send you the textBox variable is indeed a reference to the RadTextBox client-side object. So if you add the mention code to this of yours, then try modifying the rest of it as below:

    12        /* Called when a window is being shown. Good for setting an argument to the window */    
    13        function OnClientShow(radWindow) {     
    14            //Get current content of textarea     
    15            var oText = textBox;  
    16     
    17            //Create a new Object to be used as an argument to the radWindow     
    18            var arg = new Object();     
    19            //Using an Object as a argument is convenient as it allows setting many properties.     
    20            arg.TextValue = oText;     
    21            //Set the argument object to the radWindow            
    22            radWindow.Argument = arg;     
    23        }    

    I hope this helps. 

    Best wishes,
    Iana
    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.
  7. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 03 Jun 2009 Link to this post


      function CallBackFunction(radWindow, returnValue) {  
               var oArea = textbox;  
               if (returnValue) oArea.value = returnValue;  
               else alert("No text was returned");  
           } 

    The value from my dialog window produces the error : textbox is undefined.

    I apologize for any misunderstandings.

  8. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 04 Jun 2009 Link to this post

    Hi Panayiotis,

    It seems that you have missed the code in Iana's reply from yesterday. The idea is to use RadTextBox's OnLoad event to get a reference to the currently activated RadTextBox.
    To avoid further misunderstanding, I created a small sample based on her reply and attached it to this thread - please check it and use it as a base in your implementation. Note that I am using the OnClientClose function for receiving the argument - ClientCallBack is deprecated.


    All the best,
    Georgi Tunev
    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.
  9. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 04 Jun 2009 Link to this post

    Thanxs for your wonderfull support. i am still getting a javascript error , different one now : "object doesn't support this property or method"

    In my default page:

    1  <script type="text/javascript">  
    2        var textBox = null;  
    3   function Load(sender, eventArgs) {  
    4            textBox = sender;  
    5        }     
    6  
    7 function ShowDialog() {  
    8            //window.radopen(null, "DialogWindow");  
    9  
    10            //Forced reload (option 1): In order to force a reload on the dialog, the following approach should be used  
    11            //window.radopen("./SimpleDialog.aspx", "DialogWindow");  
    12  
    13            //Forced reload (option 2): If one is not sure what the current url is, forced reload can be achieved like this:  
    14            var oWnd = window.radopen(null, "DialogWindow");  
    15            oWnd.SetUrl(oWnd.GetUrl());  
    16        }  
    17  
    18        /* Called when a window is being shown. Good for setting an argument to the window */  
    19        function OnClientShow(radWindow) {  
    20            //Get current content of textarea  
    21            var oText = document.getElementById("<%=radtextbox1.ClientID %>").value;  
    22  
    23            //Create a new Object to be used as an argument to the radWindow  
    24            var arg = new Object();  
    25            //Using an Object as a argument is convenient as it allows setting many properties.  
    26            arg.TextValue = oText;  
    27            //Set the argument object to the radWindow         
    28            radWindow.Argument = arg;  
    29        }  
    30  
    31         /* Called when a window is being closed. */  
    32        function OnClientClose(sender, args) {  
    33            var oNewText = args.get_argument();  
    34        
    35            //set the needed value for the currently opened textbox  
    36            textBox.set_value(oNewText);  
    37        }  
    38  
    39 Inside my rad grid form template:
    40  
    41 <telerik:radtextbox ID="regnumber" runat="server"   
    42                                                              Text='<%# Bind("RegNumber") %>' Width="125px"<ClientEvents OnLoad="Load" /> 
    43                                                          </telerik:radTextBox> 

    Rad window manager:

    <

     

    Telerik:RadWindowManager id="Singleton" runat="server" Skin="Web20">

     

     

     

    <windows>

     

     

     

    <Telerik:RadWindow id="DialogWindow" Modal="true" Runat="server" Width="300px" Height="300px" Title="Dialog" OnClientShow="OnClientShow"

     

     

     

    OnClientClose="OnClientClose"

     

     

     

    NavigateUrl="yearSelection.aspx"></telerik:RadWindow>

     

     

     

    <Telerik:RadWindow id="RadWindow1" Modal="true" Runat="server" Width="900" Height="400" Title="Dialog"

     

     

     

    NavigateUrl="customers.aspx"></telerik:RadWindow>

     

     

     

    </windows>

     

     

     

    </Telerik:RadWindowManager>

     

     

    Please bear in mind that i am passing succesfully a value to the RadWindow from a Radtextbox outside the Radgrid (line 21).
    Then a value that gets calculated in my dialog window i want it to be passed back in the radgrid in a different radtextbox that is located inside the radgrid edit form template i created.

    In my dialog page:

    1 <body onload="ConfigureDialog();">  
    2     <form id="form1" method="post" runat="server">  
    3     <div> 
    4       <script type="text/javascript">  
    5       function GetRadWindow() {  
    6           var oWindow = null;  
    7           if (window.radWindow) oWindow = window.radWindow;  
    8           else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;  
    9           return oWindow;  
    10       }  
    11  
    12       function ConfigureDialog() {  
    13           //Get a reference to the radWindow wrapper  
    14           var oWindow = GetRadWindow();  
    15  
    16           //Obtain the argument   
    17           var oArg = oWindow.Argument;  
    18  
    19           //Use the argument  
    20           var oArea = document.getElementById("store");  
    21           oArea.value = oArg.TextValue;  
    22           oArea.style.color = oArg.Color;  
    23           oArea.style.backgroundColor = oArg.BackColor;  
    24       }  
    25  
    26  
    27       function OK_Clicked() {  
    28           var oWindow = GetRadWindow();  
    29           //Get current content of text area  
    30           var oNewText = document.getElementById("<%=reqnumber.ClientID %>").value;  
    31           alert("Req Number to be returned to main page: " + oNewText);  
    32                  //Variant2: Passing the argument to the Close method will result in the same behavior  
    33           oWindow.Close(oNewText);  
    34           //Variant3: Possible to set the Argument property of RadWindow here, and read it in the OnClientClose event handler!  
    35           //oWindow.Argument = oNewText;              
    36       }  
    37  
    38       function Cancel_Clicked() {  
    39           var oWindow = GetRadWindow();  
    40           oWindow.Close();  
    41       }               
    42  
    43  
    44 <button onclick="OK_Clicked(); return false;" class="bButton">OK</button>         
    45         <button onclick="Cancel_Clicked(); return false;" class="bButton">Cancel</button>         
    46  

    In the function ok_clicked (line 27) the message box gets succesfully displayed with the value i want to pass, closes the Radwindow but gives me the javascript error.



  10. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 04 Jun 2009 Link to this post

    Hi Panayiotis,

    Please open a support ticket and send me your project or rework the project that I posted so it reproduces the problem and attach it to the ticket - I will check it and fix it for you.


    Sincerely yours,
    Georgi Tunev
    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.
  11. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 05 Jun 2009 Link to this post

    Hi there,

    I think that  args.get_argument();   is not supported from my trial. I am using telerik 2008 Q3. DO you think that this may be the case? If yes what should i do?
    If i update from this version to the current one would my existing controls work?

    Thanxs for your patience :)


  12. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 05 Jun 2009 Link to this post

    Fixed it :
    function callbackfunction(sender, args) {  
               alert("Please enter some text in the textbox" + args);  
               var oNewText = args;  
                //set the needed value for the currently opened textbox  
               textBox.set_value(oNewText);  
           } 

    I am using the callback function and the second argument as the returned text (args)
    As i said before maybe its a version thing.

    If this is the case let me present you with another problem i am facing.
    I am following your example Window / Edit Dialog for RadGridi 
    I am opening my Radgrid in edit mode form template and i am placing a link next to a Radcombo that i want to edit that passes a key to the radwindow which is used as a select parameter for my formview. So after i edit the record and press ok
    i am using this function to refresh the grid
     function CloseAndRebind(args) {  
              var oWindow = GetRadWindow();  
                       oWindow.Close();  
                      oWindow.BrowserWindow.refreshGrid(args);  
                  } 

    The window closes but the value in the Radgrid do not get refreshed.
    This is the code i am using in the default page.
    Is there any way of refreshing only the Radcombobox with the new value.?

     function refreshGrid(arg) {  
               if (!arg) {  
                   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");  
               }  
               else {  
                   $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");  
               }  
           } 

     Private Sub RadAjaxManager1_AjaxRequest(ByVal sender As ObjectByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest  
     
            If e.Argument = "Rebind" Then 
     
                 ChequeDetailsGrid.MasterTableView.Rebind()  
            ElseIf e.Argument = "RebindAndNavigate" Then 
                'ChequeDetailsGrid.MasterTableView.SortExpressions.Clear()  
                'ChequeDetailsGrid.MasterTableView.GroupByExpressions.Clear()  
                'ChequeDetailsGrid.MasterTableView.CurrentPageIndex = ChequeDetailsGrid.MasterTableView.PageCount - 1  
                ChequeDetailsGrid.MasterTableView.Rebind()  
     
            End If 
        End Sub 

    Thanxs again for your wonderfull support.


  13. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 05 Jun 2009 Link to this post

    Hello Panayiotis ,

    Could you please clarify where is that RadComboBox which value you want to set? Is it inside the grid edit form or out of it?
    If you could open send us a sample project or at least the page with the grid and this open in the RadWindow, could help for finding a resolution for you.

    Sincerely yours,
    Iana
    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.
  14. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 05 Jun 2009 Link to this post

    It is inside the radgrid edit form template.

    Basically this is the scenario:

    1. User clicks on edit button on Radgrid. Edit template form opens. (done) 
    2. In the customers Radcombo there is a link where the selected customer number is transfered to a radwindow as a parameter to fill a formview. (done)
    3. I edit the record in formview ex change name.(done)
    4. Press Update, the Radwindow closes abd goes back in the open edit form template but the selected customer name in radcombo stays the same. (not refreshing)

     

    Thanxs , i ll try to send you a sample if you prefer though.

  15. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 10 Jun 2009 Link to this post

    Hello Panayiotis,

    Please try the attached sample and let me know if it works for you.
    Additionally, you can find more information on RadComboBox client-side API here.

    Kind regards,
    Iana
    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.
  16. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 15 Jun 2009 Link to this post

    hi thanxs for the responce,

    I dont want to return a value to the radcombobox i want the values of the radcombobox to be refreshed when radwindow closes.

     

    thanxs

    Panos Pelekanos

  17. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 15 Jun 2009 Link to this post

    Hello Panayiotis,

    In this case you need to chenge the datasource of the combo correspondingly and databind it. You can find more information on how to manipulate RadComboBox items in the below demos:

    http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/declarativedatasources/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/autocompletesql/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/combobox/examples/programming/addremovedisable/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/combobox/examples/programming/addremovedisableitemsclientside/defaultcs.aspx

    You could perform ajax request in the OnClientWindowClose event handler and handle the combo data refreshing in the AjaxRequest event. Find more information on that approach below:

    http://www.telerik.com/help/aspnet-ajax/ajxaddajaxrequesttoclientevent.html
    http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html
    http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandwindow/defaultcs.aspx?product=grid

    Best wishes,
    Iana
    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.
  18. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 16 Jun 2009 Link to this post

    Thanxs again for your support.

    I have another problem now. I am following a demo on using url for server arguments.
    I am passing my value through the selected value from an asp dropdown list succesfully though the edit form inside a radgrid.
    The problem is when i select something else from the dropdown list and click the details link the radwindow appears but passes again the first value that was loaded in the dropdown list when the radgrid edit form was loaded.  Same problem when i go to insert mode.


    Javascript  
     
      function OpenPositionedWindow(oButton, url, windowName) {  
               var oWnd = window.radopen(url, windowName);  
           }  
           function openRadWindow(CustomerID) {  
               var oWnd = radopen("customers.aspx?customernumber=" + CustomerID, "RadWindow1");  
               oWnd.center();  
                     } 

    dropDownList  
     
    <asp:DropDownList ID="customerdrop"  AppendDataBoundItems="True" runat="server" DataSourceID="customerDS"   
                                                                 DataTextField="CustomerName" DataValueField="CustomerNumber" Height="25px"   
                                                                 Width="276px" SelectedValue='<%# Bind("CustomerNumber") %>'   
                                                                  AutoPostBack="True" onselectedindexchanged="customerdrop_SelectedIndexChanged">  
                                                                  <asp:ListItem Text="-Please Select Customer-" Value="" />      
                                                             </asp:DropDownList> 
     
    Details link to pass parameter   
     
    <href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"Customernumber")%>'); return false;">  
                                Details</a> 

    <Telerik:RadWindowManager id="Singleton" runat="server"  Skin="Web20">  
                    <windows> 
                        <Telerik:RadWindow id="DialogWindow" Modal="true" Runat="server" Width="300px" Height="300px" Title="Dialog"  OnClientShow="OnClientShow" 
                    ClientCallBackFunction="OnClientClose"   
                            NavigateUrl="yearSelection.aspx"></telerik:RadWindow> 
                            <Telerik:RadWindow id="RadWindow1" Modal="true" Runat="server" Width="900" Height="400" Title="Dialog"   
                            NavigateUrl="customers.aspx"></telerik:RadWindow> 
                            <Telerik:RadWindow id="RadWindow2" Modal="true" Runat="server" Width="900" Height="500" Title="Dialog" 
                            NavigateUrl="customersall.aspx"></telerik:RadWindow> 
                    </windows> 
                </Telerik:RadWindowManager> 

    I think my problem is at the details link as it doesnt recognise that the value has been changed!
    Thanxs :)
  19. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 16 Jun 2009 Link to this post

    Hi Panayiotis,

    Indeed, the parameters in the details link onclick event are static. In order to achieve your goal, you need to change them dynamically. I suggest that in the DropDownList SelectedIndexChanged event you set the onclick attribute of the link so that the first parameter passed corresponds to the selected item.

    Regards,
    Iana
    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.
  20. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 16 Jun 2009 Link to this post

    Any code example to illustrate that?
    I am quessing i should first access the dropdownlist inside the radgrid. How do i set the onclick attribute of the link based on the selected index?

    Protected Sub customerdrop_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)  
            Dim editedItem As GridEditableItem = CType(CType(sender, DropDownList).NamingContainer, GridEditableItem)  
            Dim comboBox As DropDownList = DirectCast(sender, DropDownList)  
            Dim dataItem As GridEditableItem = DirectCast(comboBox.NamingContainer, GridEditableItem)  
            Dim combobox2 As DropDownList = DirectCast(dataItem.FindControl("customerdrop"), DropDownList) 


    Thanxs Again
  21. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 16 Jun 2009 Link to this post

    Hello Panayiotis,

    I can confirm your code for getting the DropDownList and the current edited item is proper. What is left is to set the runat property of the link control to server, assign it id and find it in the grid item with FindControl() method. If it is hard for you to work with this link on the server, replace it with a LinkButton.

    Best wishes,
    Iana
    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.
  22. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 17 Jun 2009 Link to this post

    I followed your instrunctions and now whenever i change the selected index the parameter is passed dynamically succesfully but not the first time when radgrid edit form or insert mode opens. How do i pass the allready selected value of the combobox?
    Should i copy paste the code somewhere else? (

    <href="#" runat="server"  id="detailscustomer">  
                                Details</a> 

    Protected Sub customerdrop_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)  
            Dim editedItem As GridEditableItem = CType(CType(sender, DropDownList).NamingContainer, GridEditableItem)  
            Dim comboBox As DropDownList = DirectCast(sender, DropDownList)  
            Dim dataItem As GridEditableItem = DirectCast(comboBox.NamingContainer, GridEditableItem)  
            ' To access the InsertFormItem   
            Dim combobox2 As DropDownList = DirectCast(dataItem.FindControl("customerdrop"), DropDownList)  
            Dim editLink As HtmlAnchor = DirectCast(dataItem.FindControl("detailscustomer"), HtmlAnchor)  
            editLink.Attributes.Add("onClick""return openRadWindow(" & combobox2.SelectedValue & " );")  
     
        End Sub 

    Thanxs!
  23. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Jun 2009 Link to this post

    Hello Panayiotis,

    You can leave the link definition as it was:

    <href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"Customernumber")%>'); return false;">   
       Details</a>  

    Thus it would have onclick handler initially with the default value, and then the onclick handler would change in the SelectedIndexChanged event correspondingly.

    Regards,
    Iana
    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.
  24. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 18 Jun 2009 Link to this post

    I know that this may be a general programming question but  after i put runat server to my link  it doenst work, as it gives a javascript error. My code in selected index works fine.

      <href="#"  runat="server"  id="detailscustomer" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"Customernumber")%>');return false">Details</a>   

    I think that the problem is on the double quotes that close beofre Customernumber. Is there any sollution to this problem? I tried putting escape characters but still didnt work.

    Thanxs
    Panos
  25. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 18 Jun 2009 Link to this post

    Hi Panayiotis,

    You can swap the quotes like this:

    <href="#"  runat="server"  id="detailscustomer" onclick='openRadWindow(\"<%#DataBinder.Eval(Container.DataItem,"Customernumber")%>\");return false;'>Details</a>   

    If it does not work this way, you can try setting the onclick attribute in the ItemDataBound event of RadGrid for the initial load of the link.

    Best wishes,
    Iana
    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.
  26. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 18 Jun 2009 Link to this post

     <href="#"  runat="server"  id="detailscustomer" >Details</a>   

     Protected Sub ChequeDetailsGrid_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles ChequeDetailsGrid.ItemDataBound  
     
             
            If TypeOf e.Item Is GridEditFormInsertItem AndAlso e.Item.IsInEditMode Then 
                           Dim combobox2 As DropDownList = DirectCast(TryCast(e.Item, GridEditFormInsertItem).FindControl("customerdrop"), DropDownList)  
                Dim editLink As HtmlAnchor = DirectCast(TryCast(e.Item, GridEditFormInsertItem).FindControl("detailscustomer"), HtmlAnchor)  
                editLink.Attributes.Add("onClick""return openRadWindow(" & combobox2.SelectedValue & " );")  
            End If 
     
     

    Can you spot my mistake?  The link dowesnt open radwidnow in the initial load.

    thanxs
  27. Panayiotis Pelekanos
    Panayiotis Pelekanos avatar
    26 posts
    Member since:
    Aug 2004

    Posted 18 Jun 2009 Link to this post

    I got it working now, thanxs all of you for your quidance and help.
  28. Tiffany
    Tiffany avatar
    5 posts
    Member since:
    Jun 2009

    Posted 09 Nov 2009 Link to this post

    Hi,

    I'd downloaded the sample code of Iana posted on June 10.  I was able to post back and update the value in the RadNumericTextBox inside the RadGrid control.  However, when I click the Save button on the Insert command, the Required Field validator of the RadNumericTextBox is always failed eventhough the value is set (via set_value method on client side).  I need to make sure the value in the RadNumericTextBox is > 0.  Could you please add a validation control to your sample code to see if you have the same issue as I have?  Thanks!
    Below is my client side code.   I am using RadControls Q1 2009 version.

     

    function ShowUpdateQuantityWin(quantityTxtBxId, nbrPersTextBxId, quantityList) {  
                    window.radopen("UpdateQuantity.aspx?quantityList=" + quantityList + "&quanId=" + quantityTxtBxId + "&persId=" + nbrPersTextBxId, "quantityRadWindow");  
                    var quantityTxtBx = $find(quantityTxtBxId);  
                    //quantityTxtBx.set_value(1);  
                    quantityTxtBx._textBoxElement.readOnly = false;                  
                    return false;  
                }  
     
                function OnQuantityWindowClose(oWnd) {  
                    //get the transferred arguments  
                    var arg = oWnd.argument;  
                    if (arg) {  
                        // alert("arg info: " + arg.quantity + "-" + arg.nbrOfPers + " " + arg.quanId + " " + arg.nbrPersId);  
                        $get('<%=nbrOfPersonsHF.ClientID %>').value = arg.nbrOfPers;  
                        $get(arg.nbrPersId).innerHTML = arg.nbrOfPers;  
                          
                        $get('<%=quantityHF.ClientID %>').value = arg.quantity;  
     
                        $get('<%=quantityListHF.ClientID %>').value = arg.quantityList;  
     
                        var quantityRadTxtBx = $find(arg.quanId);  
                        quantityRadTxtBx.set_value(arg.quantity);  
                        //quantityRadTxtBx.value = arg.quantity;  
                        quantityRadTxtBx.set_textBoxValue(arg.quantity);  
                          
                        quantityRadTxtBx._textBoxElement.readOnly = true;  

     

Back to Top