Client side help required

3 posts, 0 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 18 Jan Link to this post

    On My RadGrid I have a checkbox column

    <telerik:GridTemplateColumn UniqueName="colPrimaryProcedure" HeaderText="" ItemStyle-HorizontalAlign="Center"><HeaderStyle  HorizontalAlign="Center"  />
     <ItemTemplate>
      <asp:checkbox ID="chkPrimary" runat="server" />
     </ItemTemplate>
    </telerik:GridTemplateColumn>

    In the itemDatBound event I'm ading an onCLick attribute to fire a Javascript function.

    Case "Treatment Codes"
     chkPri.Attributes.Add("onclick", [String].Format("setTreatment(this);"))
     chkPri.Text = "<span style='font-size:0px;line-height:0px;'>" & e.Item.DataItem("SpecialtyProcedureId") & "</span>"
     
    In the Javascript file I'm getting the clicked on row, and also selecting a value in a RadComboBox, with Checkboxes set to true, and for each ticked row in the Rad Grid, I'm able to select a value in the combo box. This all works as expected.

    var checkBox = document.getElementById(theBox.id);
    var checkboxText = checkBox.parentElement.innerText.trim();
    comboBoxPPFUWL.findItemByValue(checkboxText).set_checked(true);

     

    What I want to do is if a box in unticked in the grid, is to un slect the row in the combo box, I'd have expected the following to work, but it doesn't.
    comboBoxPPFUWL.findItemByValue(checkboxText).set_checked(false);

    I'm using an old version of the controls 2014.2.618.40 and can't update because of breaking changes in the newer version.

    Can anyone help.

  2. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 19 Jan in reply to Andy Green Link to this post

    Hi Guys

    I have sorted this now - I had a var declared in the wrong place in my JS and was out of scope at the time I was trying to use it.

    Andy

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 20 Jan Link to this post

    Hello Andy,

    Generally, when a control is placed within a Content Page, RadGrid Template or another container which implements INamingContainer interface, its UniqueID and ClientID are modified, thus making it inaccessible on main Page level. The problem is similar when using server-side expressions like <%=txtTrackingNumber.ClientID%> in external JS files, which are not allowed.

    On server-side, you need to use the FindControl method to access the control. You can use the
    GridEditableItem item = RadGrid1.EditItems[0] as GridEditableItem; approach to get the currently edited item.

    On client-side, you have several options to resolve this:

    1. Hardcode the ClientID of the controls as the argument for $find() method.

    2. Find the control using the findControl or findElement methods:
    $telerik.findControl(document.documentElement, "txtTrackingNumber");

    3. Use the client-side event handlers of the Telerik controls to get a reference to their objects:
    Copy Code
    <telerik:RadButton ... OnClientLoad="buttonLoad">
    JavaScript:
    Copy Code
    var button;
    function buttonLoad(sender, args) {
        button = sender;
    }

    In your case, you can use the second suggestion as an alternative to the global variables.

    I hope this information will prove helpful.

    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
Back to Top