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
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