ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid crud pop up is not working while passing explicit key
Title:
B
I
{code}
?
Thanks for your prompt response. I did not understand much from your response as you have replaced Id with key. So you are passing "Id" as static key. Probably you did not understand our query. Please go through my below explaination again, If you will look at our controller code and the view mentioned above, we have set key name explicitely as "DesignationID" instead of "Id"( i.e. mentioned in awesome demo). Our designation model has property called *DesignationID*. DesignationID is our primary key. My View looks like: @(Html.Awe().Grid("DesignationGrid") .Mod(o => o.PageInfo().ColumnsSelector()) .Url(Url.Action("GetGridItems", "Designation")) .Parent("txtSearch", "search") .Height(350) .Columns( new Column { Bind = "DesignationID" }, new Column { Bind = "Name" }, new Column { Bind = "Name_OL1" }, new Column { Bind = "Name_OL2" }, new Column { ClientFormat = SalesARM.Web.UI.Utils.GridUtils.EditFormatForGrid("DesignationGrid", "DesignationID"), Width = 50 }, new Column { ClientFormat = SalesARM.Web.UI.Utils.GridUtils.DeleteFormatForGrid("DesignationGrid", "DesignationID"), Width = 50 })) and controller looks like : public ActionResult GetGridItems(GridParams g, string search) { search = (search ?? "").ToLower(); List<Designation> designationList = null; ApplicationExceptionHandler.Handle(() => { ServiceProcessComponent.Use<MasterDataServiceClient>(desiginationService => { designationList = desiginationService.GetAllDesignations(OrganisationID).OrderBy(x => x.DesignationID).ToList(); }); }); var items = designationList.Where(o => o.Name.ToLower().Contains(search)).AsQueryable(); var obj = new MasterDataServiceClient(); var data = new GridModelBuilder<Designation>(items, g) { Key = "DesignationID", // needed for api select, update, tree, nesting, EF GetItem = () => obj.GetAllDesignationsById(UserID, OrganisationID, LangID, Convert.ToInt32(g.Key)), // called by the grid.api.update ( edit popupform success js func ) Map = d => new { d.DesignationID, d.Name, d.Name_OL1, d.Name_OL2 } }.Build(); return Json(data); } So our idea here is, we dont want to use any key called "Id" in our application. Each model is having its own primary key. We are trying to implememt grid crud pop up in our application. Please see below problem statements, In edit post action, we are returning. return Json(new { model.DesignationID }); Following is our observation while debuging js code, error is comming while finding $row. itemEdited: function (gridId) { return function (item) { var $grid = $('#' + gridId); var api = $grid.data('api'); var key = $grid.data('o').k; -- Our key here is comming as "DesignationID" var xhr = api.update(item[key]); $.when(xhr).done(function () { var $row = api.select(item[key])[0]; <<------- Error coming at this place, not getting $row value ------->> var altcl = $row.hasClass("awe-alt") ? "awe-alt" : ""; $row.switchClass(altcl, "awe-changing", 1).switchClass("awe-changing", altcl, 1000); $grid.data('lrso', 1); }); }; }, Because of above error, our grid is not automatically getting refreshed. Also Delete post is not working fine, when we pass key explicitely i.e. DesignationID in DeleteFormatForGrid as shown below new Column { ClientFormat = SalesARM.Web.UI.Utils.GridUtils.DeleteFormatForGrid("DesignationGrid", "DesignationID"), Width = 50 })) Delete get method looks like as, [HttpGet] public ActionResult Delete(int DesignationID string gridId) { Designation source = null; ApplicationExceptionHandler.Handle(() => { ServiceProcessComponent.Use<MasterDataServiceClient>(masterService => { source = masterService.GetDesignationByID(DesignationID ); }); }); return PartialView(new DeleteConfirmInput { Id = DesignationID, GridId = gridId, Message = string.Format("Are you sure you want to delete product family <b>{0}</b> ?", source.Name) }); } In Delete post, Id in DeleteConfirmInput model is getting null. But when we change our key in model and in code as "Id". Its working fine. Please advise, what code changes we need to do to handle this scenario?
Save Changes
Cancel
Prakash Lad
asked at 08 Jun 2016
you need to do the changes that I explained before (the grid key remains "DesignationID")
at 08 Jun 2016
Omu
Answers
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