ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Call nest edit grid - id is null
Title:
B
I
{code}
?
when I press Edit button in grid it passes id null to the controller so i cant use nest grid for the editing. My controller: public ActionResult GridGetFaq(GridParams g, string search, string subsection) { search = (search ?? "").ToLower(); Int32 id_subsection = String.IsNullOrEmpty(subsection) ? 0 : Int32.Parse(subsection); var items = db.View_all_data.ToList().AsQueryable(); if (g.Groups != null && g.Groups.Length > 0) { g.PageSize = items.Count(); } var model = new GridModelBuilder<View_all_data>(items, g) { Key = "id_faq", Map = MapFAQ }.Build(); return Json(model); } private object MapFAQ(View_all_data o) { return new { ID = o.id_faq, Section = o.sectionName, SubSection = o.subSection, Language = o.language, Question = o.question, AnswerShort = o.answerShort, ANswerFull = o.answerFull, Tag = o.tag, Visible = o.ISVisible }; } My view: @{ var gridId = "QuestionsGrid"; } @(Html.Awe().InitPopup() .Name("Details") .Width(800) .Height(400) .Url(Url.Action("Details")) .Mod(o => o.OutClickClose())) @(Html.Awe() .InitPopupForm() .Name("Edit") .Group(gridId) .Url(Url.Action("Edit")) .Mod(o => o.Inline().ShowHeader(false)).Success("utils.refreshGrid('" + gridId + "')") ) @{ var editbutton = "<a class='btn btn-primary editnst' data-toggle=\"tooltip\" data-placement=\"top\" title=\"Edit question\"><i class='ti-pencil-alt'></i></a>"; var viewbutton = "<a class='btn btn-primary' onclick=\"awe.open('Details', {params:{id: '.(Id)'}})\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"View question details\"><i class='ti-eye'></i></a>"; } @(Html.Awe().Grid(gridId) .Resizable() .Url(Url.Action("GridGetFaq", "e_faq")) .Parent("txtSearch", "search").Parent("subsection", "subsection")//.Parent("route", "route").Parent("start", "start").Parent("end", "end") .PageSize(10) .Groupable(true).ShowGroupBar(true).ShowGroupedColumn(false) .Resizable() .Reorderable() .Page1OnSort(true) //.Mod(o => o.PageInfo().PageSize()) .Attr("data-syncg", "View_all_data") .Nests( new Nest { Name = "editnst", GetFunc = "utils.loadNestPopup('Edit')" }, new Nest { Name = "delnst", GetFunc = "utils.loadNestPopup('Delete')" } ) .Columns( new Column { Bind = "id_faq", Hidden = true }.Mod(o => o.InlineId("id_faq", "Id")), new Column { Bind = "sectionName", ClientFormat = ".(Section)", Header = @Html.DisplayNameFor(x => x.sectionName).ToString(), Width = 120 }, new Column { Bind = "subSection", ClientFormat = ".(SubSection)", Header = @Html.DisplayNameFor(x => x.subSection).ToString(), Width = 120 }, new Column { Bind = "question", ClientFormat = ".(Question)", Header = @Html.DisplayNameFor(x => x.question).ToString(), Width = 170 }, new Column { Bind = "answerFull", ClientFormat = ".(AnswerFull)", Header = @Html.DisplayNameFor(x => x.answerFull).ToString() }, new Column { Bind = "visibleOnSite", ClientFormat = ".(Visible)", Header = @Html.DisplayNameFor(x => x.visibleOnSite).ToString(), Width = 80, CssClass = "text-center" }, new Column { ClientFormat = viewbutton, Header = "View", Width = 60 }, new Column { ClientFormat = editbutton, Header = "Edit", Width = 60 } ) .SingleColumnSort(true) .Sortable(true) )
Save Changes
Cancel
Vladimir Kerzhentsev
asked at 20 Dec 2021
try adding the "id_faq" property to the Map, rename the `ID` to `Id`, `utils.loadNestPopup` expects `Id` or `id` property. `InlineId` on the column is useful when only when you're using `InlineEdit` mod on the grid. You could probably create an extension method for the `Column` to set automatically Bind, ClientFormat and Header
at 20 Dec 2021
Omu
Thanks a lot! It was enough to rename the column to id.
at 21 Dec 2021
Vladimir Kerzhentsev
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