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

Disabling buttons by default in a column

3 Answers 527 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 21 May 2014, 02:53 PM
Hello!

I am working on grid that contains user account data.  We want to allow an administrator to change the password for a given user, however, a simple change of the password is undesirable.  We want to pop up a window to allow the change to occur.  This option should _only_ be available on the row currently being edited.  I have found that I can place a button in a column through the use of the ClientTemplate.  I chose a button over a hyperlink since I read I can enable/disable the button, and have set the button to be disabled by default.  Unfortunately, when I hook into the Edit event to call the javascript, I cannot pull the button out of the <td>

Here is the grid definition:

<div id="topGrid">
@(Html.DashboardGrid<DashBUserViewModel>(svm) //GirdName, Export Method Name, Controller Name, add new class, edit template
.Columns(columns =>
{
columns.Bound(x => x.Id).Hidden(true);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(svm.cRUDColSize);
columns.Template(p => { }).ClientTemplate("<a onclick=OnSingleChange('#=Id#')>Assign Role</a>").Width(svm.cRUDColSize);
columns.Template(p => { }).ClientTemplate("<button class='myClass' disabled onclick=ChangePassword('#=Id#')>Change Password</button>").Width(svm.cRUDColSize);
// REMOVED FOR BREVITY
.Events(events => events.Cancel("showAdd").Edit("editRow").Save("showAdd")) // to blank out the template text to avoid issues
)
</div>


Here is the javascript method (the enable() method is undefined):

function editRow(currentRow) {
// Hide the add button to prevent weird errors
this.wrapper.find(".k-grid-add").hide();

if (currentRow.model.isNew()) {
currentRow.container.find("td:eq(2)").text("");
}

currentRow.container.find("td:eq(3)").enable();
}

Does anyone know how to get the button and set it to enabled?

Much thanks,

Andrew Giles

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 21 May 2014, 03:31 PM
Hi Andrew,


You could use the container parameter and find the button by class.
E.g.
currentRow.container.find(".myClass").prop('disabled', false);

Let me know if this was the information that you were looking for.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Andrew
Top achievements
Rank 1
answered on 21 May 2014, 03:39 PM
Dimeter,

I just tried to put that in, and it did not work.  I found the same thing when I attempted to reset the disabled property with an assignment.

However, I found something online about removing the attribute... and that seemed to work.

currentRow.container.find("td:eq(3)").find("button").removeAttr("disabled");


Thanks for the quick reply!

Andrew
0
Dimiter Madjarov
Telerik team
answered on 21 May 2014, 03:53 PM
Hello Andrew,


I am glad that the issue is resolved. Do not hesitate to contact us again for further problems.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or