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

How to get first cell data in child grid of hierachy grid

2 Answers 400 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 06 Oct 2013, 06:59 AM
Hi,
I m  using kendo Hierarchy  grid. In child grid I put a "edit" button. So I need to get child row first column data (ID) when I click the edit button.
 My detailInit function and clickbfunction is here.

function detailInit(e) {                       
             var    _Po_sectionID =e.data.SectionID;
                                    $("<div/>").appendTo(e.detailCell).kendoGrid({
                                        dataSource: {
                                            transport: {
                                                read: _PostionsBySectionUrl + _Po_sectionID
                                            },
                                            schema: {
                                                data: "Data",
                                                total: "Count"
                                            },                                    
                                        },
                                        scrollable: false,
                                        sortable: true,
                                        pageable: true,
                                        columns: [
                               
                                            { field: "ContainerID", title: "Possition ID",hidden:true },
                                            { field: "ContainerName", title: "ContainerName",hidden:true  },
                                            {
                                                title: "Action", width: 95, command: [
                                                          {
                                                              id: "edit",
                                                              name: "edit",
                                                              click: OnPositionRowSelect,
                                                              template: "<a class='k-button k-grid-edit' href='' style='min-width:16px;'><span class='k-icon k-edit'></span></a>"
                                                          }                                                       
                                                    ]
                                                },
                                        ]
                                    });
 } 

 function OnPositionRowSelect(e) {
                 e.preventDefault();
                 _ _ _ _ _  _ _ _ _ _   _ _ _ _ _  _ _ _ _ _  _ _ _ _ _
                 _ _ _ _ _  _ _ _ _ _   _ _ _ _ _  _ _ _ _ _  _ _ _ _ _
                _ _ _ _ _  _ _ _ _ _   _ _ _ _ _  _ _ _ _ _  _ _ _ _ _
               _ _ _ _ _  _ _ _ _ _   _ _ _ _ _  _ _ _ _ _  _ _ _ _ _
               alert("Container Id : "+ ContainerID);

 }

Regards


2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 08 Oct 2013, 12:36 PM
Hi,

 
You can use the current element from the event data to find the closest grid and get the current row dataItem from it. Please check the example below:

function OnPositionRowSelect(e) {
    e.preventDefault();
    var element = $(e.target);
    var grid = element.closest("[data-role=grid]").data("kendoGrid");
    var dataItem = grid.dataItem(element.closest("tr"));
 
    alert(dataItem.ContainerName);
}
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Håkan
Top achievements
Rank 1
answered on 09 Oct 2013, 02:23 PM
Hi Vladimir ,

Thanks a lot for your reply. That`s the thing I wanted.. Thanks again..

Bye








Tags
Grid
Asked by
Håkan
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Håkan
Top achievements
Rank 1
Share this question
or