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

[Solved] Grid pass dataitem to controller

2 Answers 244 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Garry
Top achievements
Rank 1
Garry asked on 24 Nov 2014, 02:19 PM
Hi,I have a grid with a template column;

{
    field: "",
    template: '<input type="button" class="btn btn-primary btn-xs" ng-click="openContactDialog(\'officeContactWindow\',Id=#=contactId#\,\'open\')" name="bEditContact" value="Edit" />',
    width: "60px"
},

I would like to pass the entire dataItem to my Angular Controller. I have been able to pass a value back to my controller;
{
    field: "",
    template: '<input type="button" class="btn btn-primary btn-xs" ng-click="deleteContact(dataItem)" name="bDeleteContact" value="Delete" />',
    width: "60px"
}

Is there a way of doing this?

Thanks,

George  

2 Answers, 1 is accepted

Sort by
0
Garry
Top achievements
Rank 1
answered on 24 Nov 2014, 03:13 PM
I have resolved this by using a command column instead of a template column;

columns: [
{
    field: "firstName",
    title: "First Name"
},
 
{
    command: { className: "btn btn-primary btn-xs", text: "Delete", click: deleteContact }, title: " ", width: "60px"
}

The only issue now is that even though I have added the css class names, the button height is not correct. The height should be set by the btn-xs class but for some reason it is not. Does anyone know why?

Thanks,

George
0
Garry
Top achievements
Rank 1
answered on 24 Nov 2014, 03:47 PM
This was fixed by removing the k-button class on databound;

function onDataBound(e) {
         e.sender.tbody.find(".btn-primary").removeClass("k-button");
     }
Tags
Grid
Asked by
Garry
Top achievements
Rank 1
Answers by
Garry
Top achievements
Rank 1
Share this question
or