This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to bind a grid custom command via MVVM and having no luck. i bind the function on the model inside the data-columns attribute ("command":["edit", "destroy", {"text" : "Reset password", "click": "ResetPassword" }) but the function just doesnt fire when i click the command button. Below is the markup for my girds div and the view model.
I'm going crazy here and cant seem to figure out what I'm doing wrong. I also tried this "click" : "viewModel.ResetPassword" but it also wasnt firing.
Help me someone please!
I'm trying to bind a grid custom command via MVVM and having no luck. i bind the function on the model inside the data-columns attribute ("command":["edit", "destroy", {"text" : "Reset password", "click": "ResetPassword" }) but the function just doesnt fire when i click the command button. Below is the markup for my girds div and the view model.
I'm going crazy here and cant seem to figure out what I'm doing wrong. I also tried this "click" : "viewModel.ResetPassword" but it also wasnt firing.
Help me someone please!
<div id = "TeamMembersGird" data-role="grid" data-sortable="true" data-pagable="true"data-editable='{"mode" : "popup", "confirmation" : "Are you sure you want to delete this team member?"}' data-bind="source: teamMembersSource" data-columns='[{"field":"FirstName", "title":"First name"}, {"field":"LastName", "title":"Last name"},{"field":"IsCompanyAdmin", "width":"100px", "title":"Admin"},{"title":"Action","width":"300px", "command":["edit", "destroy", {"text" : "Reset password", "click": "ResetPassword" }]}]'> </div> $(function(){ var viewModel = kendo.observable({ teamMembersSource: new kendo.data.DataSource({ transport: { read: { url: '@(Url.Action("Get", "TeamMembers", new { Area = "API" }))', data: { companyID: '@(((Signuper.WebApp.Infrastructure.SignuperProfessional)User).CompanyID)' } }, destroy: { url: '@(Url.Action("Delete", "TeamMembers", new { Area = "API" }))', type: "DELETE", datatype:"json", }, }, schema: { model: { id: "UserID", fields: { UserID: { type: "number"}, FirstName: {type: "string"}, LastName: {type: "string"}, Gender: {type:"string"}, CompanyID: {type: "number"}, IsCompanyAdmin: {type: "boolean"} } }, data: "TeamMembers", total: "TotalCount" }, batch:false, serverPaging: true, pageSize:10 }), RefreshData: function () { this.teamMembersSource.read(); }, ResetPassword : function(e) { e.preventDefault(); var dataItem = this.dataItem($(e.currentTarget).closest("tr")); ChangePasswordWindow.refresh({ url: '@Url.Action("ChangeMemberPassword", "Management", new { area = "Company" })', data: { UserID: dataItem.UserID } }); ChangePasswordWindow.center().open(); } });