BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
@(Html.EJ().Grid<ResourceAllocationViewModel>("ResourceAllocated") //.Datasource((IEnumerable<object>)ViewBag.DataSourceTmp) .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.DataSourceTmp).InsertURL("AddResourceAllocation").UpdateURL("EditResourceAllocation").RemoveURL("DeleteResourceAllocation").Adaptor(AdaptorType.RemoteSaveAdaptor)) .EditSettings(es => es.AllowEditing(true)) .ToolbarSettings(ts => ts.ShowToolbar().ToolbarItems(ti => { ti.AddTool(ToolBarItems.Add); ti.AddTool(ToolBarItems.Edit); //ti.AddTool(ToolBarItems.Delete); ti.AddTool(ToolBarItems.Update); ti.AddTool(ToolBarItems.Cancel); })) .Columns(col => { col.Field("IdResourceAllocation").Visible(false).IsPrimaryKey(true).IsIdentity(true).Add(); //col.Field("IdResource").Visible(false).IsPrimaryKey(true).Add(); col.Field("Country").HeaderText("Country").Add(); col.Field("IdResource").HeaderText("Resource").ForeignKeyField("IdResource") .ForeignKeyValue("CompleteName").DataSource((IEnumerable<object>)Model.ListaResources) .TextAlign(TextAlign.Left).Add(); col.Field("FirstName").HeaderText("First Name").Add(); col.Field("LastName").HeaderText("Last Name").Add(); col.Field("CanBeAllocated").HeaderText("Allocation").Width(100).Add(); }) .ClientSideEvents(cse => cse.BeginEdit("onBeginEditResource")) )
function onClickResource(args) { var curGridElement = this.element.closest("div[id^='child3_grid']"); var curGrid = $(curGridElement).ejGrid("instance"); var index = this.element.closest("tr").index(); var record = curGrid.getCurrentViewData()[index]; var idProject = $("#Project_IdProject").val(); var objData = { IdProject: idProject, record: record }; eDialogAllocated.position = { X: this.element.offset().left - 900, Y: this.element.offset().top }; var str = JSON.stringify(record); var jqxhr = $.post("@Url.Action("GetResourcesAllocatedCountry", "Resources")", objData) .done(function(data) { //alert(data.success); var obj = $("#ResourceAllocated").ejGrid("instance"); obj.dataSource(data.data); onOpenAllocated(); }) .fail(function(data) { alert("error"); }) .always(function() { //alert("finished"); }); }
Hi Andrea,
Thanks for using Syncfusion Products.
We have analyzed your sample and found that you have bounded the local data directly with the datasource that affects all URL’s, which is the root cause of the issue. So, we suggest you to use ej.DataManager for binding the data. While binding the data using ej.DataManager, we can include all insert/update and delete URL’s. Then, we have to bind that datamanager with the datasource.
Please find the below code snippet:
$("#button").ejButton({ click: function (args) { $.post("/Grid/Data") .done(function (data) { var genData = ej.DataManager({ json: data, updateUrl: "NormalUpdate", insertUrl: "NormalInsert", removeUrl: "NormalDelete", adaptor: "remoteSaveAdaptor" }) var gridObj = $("#FlatGrid").ejGrid("instance"); gridObj.dataSource(genData);// Datasource bind to grid }); } }); |
For your convenience we have created a sample and sample can be downloaded from the below link
Sample Link : http://www.syncfusion.com/downloads/support/directtrac/118221/Sample1182211678771919.zip
Please let us know if you have any queries,
Regards,
Prasanna Kumar N.S.V