ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
TreeCrud In 7.7 IS OK in 8.0 has ERROR
Title:
B
I
{code}
?
error message========================================= TypeError: Cannot read properties of undefined (reading 'itemEdited') at s (AwesomeMvc.js:1:913) at Object.success (AwesomeMvc.js:1:51225) at fire (jquery-3.5.1.js:3496:31) at Object.fireWith [as resolveWith] (jquery-3.5.1.js:3626:7) at done (jquery-3.5.1.js:9786:14) at XMLHttpRequest.<anonymous> (jquery-3.5.1.js:10047:9) Index.cshtml ====================================================== <h2>?????</h2> @(Html.Awe().Grid("MenuTreeGrid") .Url(Url.Action("LazyTree", "MenuTree")) .Columns( new Column { Bind = "Name" }, new Column { Bind = "ID", Width = 100 }, new Column { Bind = "ControllerName" }, new Column { Bind = "ViewName" }, new Column { Bind = "Icon" }, new Column { Bind = "ImageUrl" }, new Column { Bind = "LanguageKey" } ) .Groupable(false) .PageSize(3) .Height(400))*@ @{ var crudgrid = "CrudMenuTreeGrid"; } @(Html.InitCrudPopupsForGrid(crudgrid, "MenuTree", 200, cfg: (opt, act) => { if (act == "create") { opt.OnSuccess = "nodeCreated"; } })) @(Html.Awe().InitPopupForm() .Name("createNode") .Height(200) .Group("tree") .Url(Url.Action("Create", "MenuTree")) .Success("nodeCreated")) @(Html.Awe().InitPopupForm() .Name("editNode") .Height(200) .Group("tree") .Url(Url.Action("Edit", "MenuTree")) .Success("utils.itemEdited('CrudMenuTreeGrid')")) @(Html.Awe().InitPopupForm() .Name("deleteNode") .Height(200) .Modal() .Group("tree") .Url(Url.Action("Delete", "MenuTree")) .Success("utils.itemDeleted('CrudMenuTreeGrid')") .OnLoad("utils.delConfirmLoad('CrudMenuTreeGrid')") .Parameter("gridId", crudgrid)) <div class="bar"> @Html.Awe().Button().Text("?????").OnClick(Html.Awe().OpenPopup("createNode")) @*<button type="button" class="awe-btn" style="float: left;" onclick="awe.open('createNode')">?????</button>*@ @*<button type="button" class="awe-btn" style="float: left;" onclick="awe.open('create@(crudgrid)')">add root</button>*@ <div style="text-align: right;"> @Html.Awe().TextBox("txtname").Placeholder("search...").CssClass("searchtxt") </div> </div> @(Html.Awe().Grid(crudgrid) //.Mod(o => o.CustomRender("sideMenu.menutree").Loading(false)) .Mod(o => o.PageInfo().ColumnsSelector()) .Url(Url.Action("CrudMenuTree", "MenuTree")) .Columns( new Column { Bind = "Name",Header="?????", ClientFormatFunc = "nameshow", Width = 700 }, new Column { Bind = "ID", Header = "ID", Width = 80, Hidden = true }, new Column { Bind = "ParentID", Header = "??ID", Width = 100, Hidden = true }, new Column { Bind = "Seq", Header = "??", Width = 100, Hidden = true }, new Column { Bind = "ID", Header = "", ClientFormatFunc = "AddChild", Width = 120 }.Mod(o => o.Nohide()), //new Column { ClientFormat = GridUtils.AddChildFormat(crudgrid), Width = 120 }, //new Column { ClientFormat = GridUtils.EditFormatForGrid(crudgrid), Width = GridUtils.EditBtnWidth }, //new Column { ClientFormat = GridUtils.DeleteFormatForGrid(crudgrid), Width = GridUtils.DeleteBtnWidth }) new Column { ClientFormatFunc = "editopen", Width = 90 }.Mod(o => o.Nohide()), new Column { ClientFormat = GridUtils.DeleteFormat("deleteNode","ID"), Width = 60, Header = "" }) .Resizable() .PageSize(10) .Parent("txtname", "name") .Groupable(false) //.ShowFooter(false) //.ShowHeader(false) //.ShowGroupBar(false) //.ColumnWidth(200) .Height(700)) @*<label style="font-size:x-large"></label>*@ <script> // needed to handle crud when search criteria is present // (e.g. if you add a child and update the node it might not show up because of the search criteria) var nodesAdded = []; $(function () { var api = $('#@(crudgrid)').data('api'); api.load({ sort: [{ Prop: "ParentID", Sort: 1 }, { Prop: "Seq", Sort: 1 }],// direction 0 = none, 1 = asc, 2 = desc }) $('#@(crudgrid)').on('aweload', function () { nodesAdded = []; }); }); function nodeCreated(res) { var grid = $('#@(crudgrid)'); var api = grid.data('api'); nodesAdded.push(res.Node.Id); // update parent if present of reload the grid with empty sorting and grouping rules if (res.ParentId) { var xhr = api.update(res.ParentId, { nodesAdded: nodesAdded }); $.when(xhr).done(function () { if (res.Node) { awe.flash(api.select(res.Node.Id)[0]); } }); } else { var row = api.renderRow(res.Node, 1);// render row as lvl 1 (root) grid.find('.awe-content .awe-itc').prepend(row); } } function AddChild(row, prop) { var str = "<button type=\"button\" class=\"awe-btn awe-nonselect o-pad\" onclick=\"awe.open('createNode', { params: { parentId: " + row[prop] + " } })\">?????</button>"; //"<button type='button' class='awe-btn awe-nonselect o-pad' onclick=\"awe.open('createNode', { params:{ parentId: '.(Id)' } })\">add child</button>" return str; } function nameshow(row, prop) { var str = "<i class=\"" + row["Icon"] + " fa-2x\"></i>" + "<label style=\"font-size: x-large\">" + row[prop]+"</label>" ; //"<button type='button' class='awe-btn awe-nonselect o-pad' onclick=\"awe.open('createNode', { params:{ parentId: '.(Id)' } })\">add child</button>" return str; } function editopen(itm) { var rval = "<button type=\"button\" class=\"awe-btn\" onclick=\"awe.open('editNode', { params: { id:'" + itm.ID + "'} }, event)\">??</button>"; //awe.open('editCrudMenuTreeGrid', { params:{ id: '' } }, event) return rval; } </script>
Save Changes
Cancel
RayBen
asked at 19 Aug 2024
in 8.0 utils.js has been renamed to aweUtils.js, so your code can't find `utils.itemEdited` please have a look here: https://www.aspnetawesome.com/learn/release/Version8-0#Migrating-from-previous-versions
at 19 Aug 2024
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