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

Updating item manually client-side using GridTemplateColumn columns

2 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fernando Mayorga
Top achievements
Rank 1
Fernando Mayorga asked on 09 Sep 2009, 10:29 PM
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 Answers, 1 is accepted

Sort by
0
Fernando Mayorga
Top achievements
Rank 1
answered on 14 Sep 2009, 02:33 PM
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.
0
Accepted
Veli
Telerik team
answered on 15 Sep 2009, 06:40 AM
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.
Tags
Grid
Asked by
Fernando Mayorga
Top achievements
Rank 1
Answers by
Fernando Mayorga
Top achievements
Rank 1
Veli
Telerik team
Share this question
or