ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Getting Id of selected row on clicking delete button.
Title:
B
I
{code}
?
Hi! I have bound my grid to a js function for getting data. my js function is providing data which is present in a js object array, every array element have Id property, as the grid is not backed by a model but a js array, every row has delete button, as grid does not have a model on back so how do I get Id of selected row on clicking delete button? This function is providing data to grid: function getTypeGridData(gp) { var g = utils.getGridParams(gp); function map(o) { return { Id: o.Id, Name: o.Name, TypeName: o.TypeName, Description: o.Description, IsDeleted : o.IsDeleted }; }; return utils.gridModelBuilder(this, g, typesList, { key: "Id", map: map }); } and grid is like : @(Html.Awe().Grid("TypeGrid") .DataFunc("getTypeGridData") .Sortable(true) .Mod("loadingGrid") .Columns( new Column { ClientFormat = ".Id", Hidden = true }, new Column { Header = "Name", Name = "Name" Sort = Omu.AwesomeMvc.Sort.Asc }, new Column { Header = "Delete", ClientFormatFunc = "utils.deleteFormat('deleteTypeGrid','TypeGrid')"})) As utils.deleteFormat always get the model of row but here model is not present, just a js array which is providing data , so how do I implement delete function for a row?? or how to get Id from row when click delete.
Save Changes
Cancel
Sam Mosaic
asked at 18 Sep 2019
Answers
B
I
{code}
?
ok, so the grid row model is the one you defined in `map`, so if you set ClientFormatFuc = "myfunc" and having: function myfunc(model){ console.log(model); // you'll see here the model with all the properties // so you could return return '<button type="button" onclick="myDeleteFunc(\'' + model.Id + '\')">delete</button>'; } of course you could also use `ClientFormat`, more examples here: https://demo.aspnetawesome.com/GridDemo/CustomFormat
Save Changes
Cancel
Omu
answered at 18 Sep 2019
Thanks a lot.. You saved my hours.
at 18 Sep 2019
Sam Mosaic
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK