Updating item manually client-side using GridTemplateColumn columns

3 posts, 1 answers
  1. Fernando Mayorga
    Fernando Mayorga avatar
    4 posts
    Member since:
    Jul 2009

    Posted 09 Sep 2009 Link to this post

    I have a client-side bound grid via WCF that I would like to update (edit) completely at client-side.
    I read and downloaded an example Vladimir E. here. The example uses an ItemTemplate to present the editor controls.  I am trying to achieve something very similar but instead using GridTemplateColumn with a RadTextBox inside.
    I trigger the following code onBlur client event:

    function updateItem(sender, e) {
    var parent = $find(Telerik.Web.UI.Grid.GetFirstParentByTagName(sender._element, "tr"));
    var item = parent.id;
    var columns = tableView.get_columns();
    var dataItem = item.get_dataItem();

    var newObject = new Object();
    return false;
    }


    The var "parent" is always null I tried to use sender._parent, sender._element.parenNode, etc without success.

    This is how the GridTemplateColumn looks like:

    <telerik:GridTemplateColumn SortExpression="EntryId" DataField="EntryId" HeaderText="EntryId">
    <ItemTemplate>
                         <telerik:RadTextBox ID="txtEntryId" runat="server" Width="80px" ClientEvents-OnBlur="updateItem" />
                     </ItemTemplate>
    </telerik:GridTemplateColumn>

    I could not find any documentation on the method Telerik.Web.UI.Grid.GetFirstParentByTagName, can you guys please point me in the right direction?

    Thanks in advanced,

    Fernando M.

  2. Fernando Mayorga
    Fernando Mayorga avatar
    4 posts
    Member since:
    Jul 2009

    Posted 14 Sep 2009 Link to this post

    Hi, just wondering if there is any response for this?

    is the use of $find(Telerik.Web.UI.Grid.GetFirstParentByTagName(sender._element, "tr")); supported?

    thanks.
  3. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 15 Sep 2009 Link to this post

    Hello Fernando,

    The GetFirstParentByTagName() method is supported and here is its implementation:

    Telerik.Web.UI.Grid.GetFirstParentByTagName = function (node, tagName) 
        while (node && node.parentNode) 
        { 
            if (node.tagName.toLowerCase() == tagName.toLowerCase()) 
            { 
                return node; 
            } 
            node = node.parentNode; 
        } 
        return null

    As you can see, it simply loops over the parent nodes of the node argument (HTML DOM element) and tries to find a parentNode with a matching tag name. The problem in your case seems to originate from elsewhere.

    If you notice in Vladimir's blog post, we use:

    var item = $find(Telerik.Web.UI.Grid.GetFirstParentByTagName(sender, "tr").id);

    $find() expects an ID to find an object associated with this ID. You seem to pass it a DOM element.

    Sincerely yours,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top