Disable row selection in mvc and Enable column selection in mvc kendo grid - kendo-grid

I want to Disable the row selection and enable only column selection kendo grid MVC. Here is my code. I want to select the kendo grid cells only now the whole row like I want only the coordinates.
columns.Bound(p => p.H).HtmlAttributes(new { title = "#= H #" });
columns.Bound(p => p.I).HtmlAttributes(new { title = "#= I #" });
columns.Bound(p => p.J).HtmlAttributes(new { title = "#= J #" });
columns.Bound(p => p.K).HtmlAttributes(new { title = "#= K #" });
columns.Bound(p => p.L).HtmlAttributes(new { title = "#= L #" });
columns.Bound(p => p.M).HtmlAttributes(new { title = "#= M #" });
columns.Bound(p => p.N).HtmlAttributes(new { title = "#= N #" });
columns.Bound(p => p.O).HtmlAttributes(new { title = "#= O #" });
columns.Bound(p => p.P).HtmlAttributes(new { title = "#= P #" });
columns.Bound(p => p.Q).HtmlAttributes(new { title = "#= Q #" });
columns.Bound(p => p.R).HtmlAttributes(new { title = "#= R #" });
columns.Bound(p => p.S).HtmlAttributes(new { title = "#= S #" });
columns.Bound(p => p.T).HtmlAttributes(new { title = "#= T #" });
columns.Bound(p => p.U).HtmlAttributes(new { title = "#= U #" });
columns.Bound(p => p.V).HtmlAttributes(new { title = "#= V #" });
columns.Bound(p => p.W).HtmlAttributes(new { title = "#= W #" });
columns.Bound(p => p.X).HtmlAttributes(new { title = "#= X #" });
columns.Bound(p => p.Y).HtmlAttributes(new { title = "#= Y #" });
columns.Bound(p => p.Z).HtmlAttributes(new { title = "#= Z #" });
})
.Selectable(s => s.Mode(GridSelectionMode.Single))
.Scrollable()
.Navigatable()
.HtmlAttributes(new { style = "cursor:pointer;height:860px;width:1120px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetDefaultPlotSitePlan", "Grid")))
.Events(e => e.DataBound("onDataBoundSitePlanPlot").Change("onSelectSitePlanRow").Navigate("onRowNavigateUsingKeyboard"))
)

You should state that the selection type is cell, like this:
.Selectable(s => s
.Mode(GridSelectionMode.Single)
.Type(GridSelectionType.Cell))

Related

Telerik Net Core Grid, display checkbox column in TileLayout

Telerik Net Core Grid, display checkbox column in TileLayout.
Without TileLayout grid is working fine. But in TileLayout when i using ClientTemplate to show checkbox,compiler give me error:'Uncaught ReferenceError: Id is not defined'.I'm assuming it's related to the nested ClientTemplate, but how to avoid this problem to display the checkbox?
#(Html.Kendo().TileLayout()
.Name("tilelayout")
.Columns(100)
.RowsHeight("100%")
.Height("100%")
.ColumnsWidth("100%")
.Containers(c => {
c.Add().Header(h => h.Text("Входящие документы")).BodyTemplateId("inboxdocuments").ColSpan(75).RowSpan(2);
c.Add().Header(h => h.Text("Прикрепленные документы")).BodyTemplateId("attachments").ColSpan(25).RowSpan(1);
c.Add().Header(h => h.Text("Рассылка")).BodyTemplateId("distributions").ColSpan(25).RowSpan(1);
})
.Reorderable()
.Resizable()
.Events(e=>e.Resize("onTileResize"))
)
```
<script id="inboxdocuments" type = "text/x-kendo-template">
<input type="hidden" id="DocumentId" value="">
#(Html.Kendo().Grid<Billing.Workflow.Models.DTO.InboxDocumentDTO>()
.Name("InboxDocumentsGrid")
.Columns(columns =>
{
columns.Bound(e => e.Id).Title("№").Width(100);
columns.Bound(e => e.RegistrationDate).Title("Дата").Format("{0: dd.MM.yyyy}").Width(125);
columns.Bound(e => e.RegistrationNumber).Title("№ документа").Width(150);
columns.Bound(e => e.Applicant).Title("Откуда").Width(250);
columns.Bound(e => e.DeadlineDate).Title("Срок до").Format("{0: dd.MM.yyyy}").Width(125);
**columns.Bound(e => e.IsForInformation).ClientTemplate("<input type='checkbox' value='#= Id #' " + "# if (IsForInformation) { #" + "checked='checked'" + "# } #" + "/>").Title("Для информации").Width(150);**
columns.Bound(e => e.IsForControl).Title("Для контроля").Width(150);
columns.Bound(e => e.ReminderDate).Title("Дата напоминания").Format("{0: dd.MM.yyyy}").Width(200);
columns.Bound(e => e.User).Title("Пользователь").Width(300);
columns.Bound(e => e.Account).Title("ЛС/№ контракта").Width(200);
columns.Bound(e => e.ApplicantFullName).Title("ФИО").Width(300);
columns.Bound(e => e.ApplicantAddress).Title("Адрес").Width(300);
columns.Bound(e => e.DocumentNumber).Title("Входящий номер").Width(200);
columns.Bound(e => e.DocumentDate).Title("Дата вх.документа").Format("{0: dd.MM.yyyy}").Width(125);
columns.Bound(e => e.Summary).Title("Краткое содержание").Width(300);
columns.Bound(e => e.Note).Title("Комментарий").Width(500);
columns.Bound(e => e.Mail).Title("Эл.адрес").Width(200);
})
.ToolBar(toolbar =>
{
toolbar.Excel();
toolbar.Custom().Text("Создать входящий документ").IconClass("k-icon k-i-download");
toolbar.Custom().Text("Создать исходящий документ").IconClass("k-icon k-i-upload");
toolbar.Search();
}
)
.Mobile()
.Pageable()
.Scrollable()
.Sortable()
.Filterable()
.Selectable()
.Navigatable()
.ColumnMenu()
.Resizable(resize => resize.Columns(true))
.HtmlAttributes(new { style = "height:99%" })
.DataSource(datasource =>
datasource
.Ajax()
.PageSize(100)
/*.ServerOperation(false)*/
.Read(read => read.Action("GetInboxDocuments", "Reception"))
)
.Events
(
events=>events
.Change("onChange")
.DataBound("onInboxdocumentsDataBound")
)
.Excel(excel => excel
.Collapsible(true)
.AllPages(true))
.ToClientTemplate()
)
</script>

Kendo Grid Exporting of Live Data

For the life of me, I cannot determine a solution to this. I have a Kendo Grid that grabs random part numbers for an audit. However, when I export the grid to Excel, it executes the datasource again, resulting in different part numbers.
I would like to just export what is displayed on the screen and not execute the datasource again.
How do I do this?
Here is a subset of the code:
<section class="panel">
#(Html.Kendo().Grid<DTO.GenerateRandomPartNumsList>()
.Name("RandomNumberGeneratorGrid")
.Columns(columns => {
columns.Bound(p => p.VendorName).ClientTemplate("<div class='cell-with-copy'><div>#:VendorName #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.PartNo).ClientTemplate("<div class='cell-with-copy'><div>#:PartNo #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.OnHand).ClientTemplate("<div class='cell-with-copy'><div>#:OnHand #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.PartDesc).ClientTemplate("<div class='cell-with-copy'><div>#:PartDesc #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.Bin).ClientTemplate("<div class='cell-with-copy'><div>#:Bin #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.PackageQuantity).ClientTemplate("<div class='cell-with-copy'><div>#:PackageQuantity #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.Cost).ClientTemplate("<div class='cell-with-copy float-right'><div>#:Cost #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
columns.Bound(p => p.TotalValue).ClientTemplate("<div class='cell-with-copy float-right'><div>#:TotalValue #</div><i class='fas fa=clipboard icon-copy'></i></div>")
.HtmlAttributes(new { #class = "k-hover" }).Width(125);
})
.Pageable(pager => pager.AlwaysVisible(true).PageSizes(new int[] {minRecords,
(minRecords * 2),
(minRecords * 3),
(minRecords * 4)}))
.Sortable()
.Resizable(resize => resize.Columns(true))
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Single)
.Type(GridSelectionType.Cell))
.Navigatable()
.Events(ev => ev.Change("copyCell"))
.AllowCopy(true)
.Scrollable()
//.Filterable()
.ToolBar(toolbar => {
toolbar.ClientTemplateId("RandomNumberGeneratorToolBar");
})
.Excel(excel=>excel
.FileName("RandomPartNumbers.xlsx")
.AllPages()
.ProxyURL(Url.Action("Excel_Export_Save", "RandomPartNumbers"))
)
.Pdf(pdf => pdf
.AllPages()
.AvoidLinks()
.PaperSize("A4")
.Margin("2cm", "1cm", "1cm", "1cm")
.RepeatHeaders()
.Landscape()
.Scale(.5)
.TemplateId("page-template")
.FileName("RandomPartNums.pdf")
.ProxyURL(Url.Action("Pdf_Export_Save", "RandomPartNums"))
)
.Search(search =>
{
search.Field(f => f.VendorName)
.Field(f => f.PartNo)
.Field(f => f.PartDesc)
.Field(f => f.Bin);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(minRecords)
.Read(read => read.Action("ReadRandomPartsNumbers", "Parts")
.Data("getFilterData"))
)
.LoaderType(Kendo.Mvc.UI.GridLoaderType.LoadingPanel)
)
</section>
Thanks to Tawab Wakil for finding this:
Reference: Kendo Grid MVC / export to Excel without additional request
.DataSource(ds => ds
.Ajax()
.PageSize(30)
.Read(r => r.Action("GetTaskItems", "Home")
.Type(HttpVerbs.Get))
.ServerOperation(false)
))
The .ServerOperation(false) is what did the trick

Kendo grid column - show text when editing

I have a kendo grid in a page
I need to show a text when the user start editing a specified column from the grid.
Here is the grid:
#(Html.Kendo().Grid<GGISServices.Models.SilviPrio.GenerateDocumentViewModel>()
.Name("grid")
.AutoBind(false)
.Columns(columns =>
{ ...
columns.Bound(c => c.TreeQ4)
.HeaderTemplate("<a class='k-link' href=''>"+ LanguageService.Instance.Translate("Enum_TreeGroup_4") +"<br><span class='subtitle'>" + LanguageService.Instance.Translate("Trees_MeasurementUnits") + "</span></a>")
.HtmlAttributes(new { #class = "tree-q4 pvrf-data tree-column" }).Sortable(true)
.Filterable(f => f.Multi(true).DataSource(ds => ds.Read(r => r.Action("GetFilterData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Type(HttpVerbs.Post).Data("{ field: 'TreeQ4', fieldtype: 'decimal' }"))));
columns.Bound(c => c.TreeQ1)
.HeaderTemplate("<a class='k-link' href=''>" + LanguageService.Instance.Translate("Enum_TreeGroup_1") + "<br><span class='subtitle'>" + LanguageService.Instance.Translate("Trees_MeasurementUnits") + "</span></a>")
.HtmlAttributes(new { #class = "tree-q1 pvrf-data tree-column" }).Sortable(true)
.Filterable(f => f.Multi(true).DataSource(ds => ds.Read(r => r.Action("GetFilterData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Type(HttpVerbs.Post).Data("{ field: 'TreeQ1', fieldtype: 'decimal' }"))));
columns.Bound(c => c.TreeQ2)
.HeaderTemplate("<a class='k-link' href=''>" + LanguageService.Instance.Translate("Enum_TreeGroup_2") + "<br><span class='subtitle'>" + LanguageService.Instance.Translate("Trees_MeasurementUnits") + "</span></a>")
.HtmlAttributes(new { #class = "tree-q2 pvrf-data tree-column" }).Sortable(true)
.Filterable(f => f.Multi(true).DataSource(ds => ds.Read(r => r.Action("GetFilterData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Type(HttpVerbs.Post).Data("{ field: 'TreeQ2', fieldtype: 'decimal' }"))));
columns.Bound(c => c.TreeQ5)
.HeaderTemplate("<a class='k-link' href=''>" + LanguageService.Instance.Translate("Enum_TreeGroup_5") + "<br><span class='subtitle'>" + LanguageService.Instance.Translate("Trees_MeasurementUnits") + "</span></a>")
.HtmlAttributes(new { #class = "tree-q5 pvrf-data tree-column" }).Sortable(true)
.Filterable(f => f.Multi(true).DataSource(ds => ds.Read(r => r.Action("GetFilterData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Type(HttpVerbs.Post).Data("{ field: 'TreeQ5', fieldtype: 'decimal' }"))));
columns.Bound(c => c.TreeQ3)
.HeaderTemplate("<a class='k-link' href=''>" + LanguageService.Instance.Translate("Enum_TreeGroup_3") + "<br><span class='subtitle'>" + LanguageService.Instance.Translate("Trees_MeasurementUnits") + "</span></a>")
.HtmlAttributes(new { #class = "tree-q3 pvrf-data tree-column" }).Sortable(true)
.Filterable(f => f.Multi(true).DataSource(ds => ds.Read(r => r.Action("GetFilterData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Type(HttpVerbs.Post).Data("{ field: 'TreeQ3', fieldtype: 'decimal' }"))));
columns
.Bound(c => c.SilviPrioId)
.ClientTemplate(
"#= actionDetails(data) #"
)
.Title(LanguageService.Instance.Translate("GridLabel_Action"))
.Filterable(false)
.Sortable(false)
.HtmlAttributes(new { #class = "action-column" });
})
.ToolBar(toolbar =>
{
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.Filterable()
//.Selectable(selection => selection.Enabled(true))
.Selectable(selection => selection.Mode(GridSelectionMode.Single))
//.Events(e => e.DataBound("SaveState").ExcelExport("ShowLoading"))
.Pageable(pageable => pageable
.Refresh(true)
.Info(true)
.PageSizes(new int[] { 5, 10, 25, 50, 100, 1000 })
.ButtonCount(5)
)
.Events(events => events
.Change("onChange")
.DataBound("onDataBound")
.DataBinding("onDataBounding")
.Edit("onEditing")
.SaveChanges("onSavingChanges")
)
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Events(events => events
.Error("error_handler")
.RequestEnd("request_end_handler")
)
.Model( model =>
{
model.Id(p => p.SilviPrioId);
model.Field(p => p.Region).Editable(false);
model.Field(p => p.CostCenter).Editable(false);
model.Field(p => p.UP).Editable(false);
model.Field(p => p.UA).Editable(false);
model.Field(p => p.MeasurementUnit).Editable(false);
model.Field(p => p.PlannedQuantity).Editable(false);
model.Field(p => p.PlannedUnitPrice).Editable(false);
})
.Read(read => read.Action("GetData", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }))
.Update(update => update.Action("Editing_Update", "Document", new { Area = GGISWeb.AreaModules.SilviPrio }).Data("additionalUpdateInfo"))
.PageSize(25)
)
.Resizable(resize => resize.Columns(true))
)
I need to show a text, something like this,
enter image description here
but immediately when the user starts editing the fields TreeQ4, TreeQ1
I have searched on the net, and I have founded something with the HtmlAttributes(title, but it is not working like this.
Can you please advise how can I resolve?
Use the kendo grid edit event and then append the text to a html element in the event function.

How to fix the rounding issue in kendo grid for column.

I am using kendo Grid where i am binding the string value 723086288701357234 in a column which is rounded as `723086288701357200'. I thought its the issue because of bounding the int type model to column so i change it with string but the issue still exists.
bellow the Grid binding.
#(Html.Kendo().Grid<Assets>().Name("rgdSearchTrackingDevices").HtmlAttributes(new { #Style = "text-align:left;font-size:8pt;;width:99%;visibility:hidden;" }).Columns(columns =>
{
columns.ImageColumn("<span class='spirtgrid sprite-Search' title='View' onclick=\"ViewManageDeviceDetails('#=AssetID#') \"></span>").Filterable(false).Groupable(false).Sortable(false).HtmlAttributes(new { #style = "width:30px; text-align:center;" }).HeaderHtmlAttributes(new { #style = "width:30px;" }).Title("View");
columns.ImageColumn("<span class='spirtgrid sprite-Controls' title='Control' onclick=\"ControlDevice('#=AssetID#','#=CompanyID#') \"></span>").Filterable(false).Groupable(false).Sortable(false).HtmlAttributes(new { #style = "width:40px; text-align:center;" }).HeaderHtmlAttributes(new { #style = "width:40px;" }).Title("Control");
columns.Bound(x => x.Alias).Filterable(HtmlExtensions.BoundColumnFilter).ClientTemplate("<span class='link' onclick=\"ViewManageDeviceDetails('#=AssetID#')\">#=Alias#</span>").Filterable(HtmlExtensions.BoundColumnFilter);
columns.Bound(x => x.MDN).ClientTemplate("<span class='link' onclick=\"ViewDeviceDetails('#=AssetID#')\">#=AssetKey#</span>").Filterable(HtmlExtensions.BoundColumnFilter).Title("MDN");
columns.Bound(x => x.IMEI);
columns.Bound(x => x.BatteryPercentage_Converted).Title("Battery %");
columns.Bound(x => x.Company.Company1).Title("Company").ClientTemplate("<span class='link' onclick=\"ViewCompanyDetails('#=CompanyID#')\">#=Company.Company1#</span>").Filterable(HtmlExtensions.BoundColumnFilter);
columns.Bound(x => x.DeviceType.DeviceType1).Title("Device Type").HtmlAttributes(new { #style = "width:130px;" }).HeaderHtmlAttributes(new { #style = "width:130px;" }).Filterable(HtmlExtensions.BoundColumnFilter);
})
.DataSource(datasource => datasource.Ajax()
.Read(read => read.Action(Constants.ControllerName.UserControls_Device, Constants.ActionName.ReadSearchDevice).Data("searchData_TrackingDevice")))
.Filterable(HtmlExtensions.FilterConfiguration)
.Filterable(x => x.Extra(false))
.Sortable(sort => sort.Enabled(true))
.AutoBind(false)
.Resizable(resize => resize.Columns(true))
.Pageable(pagable => pagable.PageSizes(pageSize))
.Scrollable(scroll => scroll.Enabled(true))
.Events(e => e.DataBound("rgdSearchTrackingDevices_DataBound"))
)
here in MDN column i am getting the issue.Please suggest where i am doing wrong.Thank you.

My kendo grid is duplicating records

I have a kendo gri in my application.
Here's a picture of it.
And here's the code
#(Html.Kendo().Grid<TekstenViewModel.Tekst>()
.Name("Grid")
.Columns(columns =>
{
columns.Template(#<text></text>).ClientTemplate("<input type='checkbox'/>").Width(10).Hidden(!Model.Administrator);
columns.Bound(product => product.RESOURCE_SET_NAAM).ClientTemplate("#= RESOURCE_SET_NAAM#");
columns.Bound(product => product.Naam).ClientTemplate("#= Naam#");
columns.Bound(product => product.Waarde).ClientTemplate("<div id='editorDiv'><div class='input'>#if(Waarde){# #if(Waarde.length>100){# # var myContent =Waarde; # # var dcontent = myContent.substring(0,100); # <span>#=kendo.toString(dcontent)#</span> #}else{# <span>#=Waarde#</span> #}# #}#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.Edit, htmlAttributes: new { onclick = "openPopupDemo('#: Waarde #', '#: ID #', 'Waarde')" }));
columns.Bound(product => product.Opmerking).ClientTemplate("<div id='editorDiv'><div class='input'>#if(Opmerking){# #if(Opmerking.length>100){# # var myContent =Opmerking; # # var dcontent = myContent.substring(0,100); # <span>#=kendo.toString(dcontent)#</span> #}else{# <span>#=Opmerking#</span> #}# #}#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.Edit, htmlAttributes: new { onclick = "openPopupDemo('#: Opmerking #', '#: ID #', 'Opmerking')" }));
columns.Template(#<text></text>).ClientTemplate("<div id='deleteDiv'><div class='delete'><a class=\"delete iconBtn\" onclick=\"deleteResourceItem(#: ID #, '#: Naam #')\"></a></div></div>").Width(10).Hidden(!Model.Administrator);
})
.Pageable()
.Sortable()
.Filterable()
.Events(events => events.Edit("onCellEdit").DataBinding("onDataBinding").DataBound("onDataBound"))
.Groupable()
.Resizable(a => a.Columns(true))
.Navigatable()
.Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.Events(e => e.Error("error_handler"))
.Model(model =>
{
model.Id(product => product.ID);
model.Field(product => product.Naam).Editable(Model.Administrator);
model.Field(product => product.Opmerking).Editable(Model.Administrator);
model.Field(product => product.Waarde).Editable(!Model.ReadOnly);
model.Field(product => product.RESOURCE_SET_ID).DefaultValue(Model.SetID);
model.Field(product => product.Type).DefaultValue(Domain.Agromilieu2.Common.Objects.Entities.Resources.ResourceType.GLOBAL_RESOURCES);
model.Field(product => product.Taal).DefaultValue(Domain.Agromilieu2.Common.Agromilieu2Constants.Resources.DEFAULT_TAAL_CODE);
})
.Create(create => create.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Create, MVC.BeheerTeksten.Name).Data("onCreateAdditionalData"))
.Read(read => read.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Read, MVC.BeheerTeksten.Name, new { setID = Model.SetID }).Data("onReadAdditionalData"))
.Update(update => update.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Update, MVC.BeheerTeksten.Name).Data("onAdditionalData"))
.Destroy(destroy => destroy.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Delete, MVC.BeheerTeksten.Name))
)
)
The grid works just fine, except when I create a new record. It calls the method to create, saves the record on the database, etc, no problem.
But when I return to the view, the record I just add appears as a duplicate of the first record inserted in the table.
Yes, I know it sounds strange but it's true. I've tried several times with different values, but I always get the same result.
Every new record is shown as a duplicate of the first record added to the grid. Off course, if I refresh the page, the data is correct.
Here's an example.
The grid before adding a new record.
The grid after inserting a new record.
Finally, after saving changes, I get this. If I refresh the page, the data is correct.
And here's my create method.
[AcceptVerbs(HttpVerbs.Post)]
[Domain.BasisArchitectuur.Framework.MVC.ActionFilters.MenuItem("Teksten")]
[IsAgromilieuActieAllowed(ActieClaims.TekstenBeheren)]
public virtual ActionResult ResourceItems_Create([DataSourceRequest]DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<TekstenViewModel.Tekst> resourceItems, long setID, string toepassingsCode)
{
List<ResourceItemDto> entities = new List<ResourceItemDto>();
if (ModelState.IsValid && SecurityHelper.IsActieAllowed(ActieClaims.TekstenBeheren))
{
try
{
using (IProxy<IResourceService> proxy = _proxyFactory.Create<IResourceService>())
{
foreach (TekstenViewModel.Tekst tekstenViewModel in resourceItems)
{
ResourceItemDto resourceItem = new ResourceItemDto
{
ResourceItem_ID = tekstenViewModel.ID,
ResourceSet_ID = setID,
Naam = HttpUtility.HtmlDecode(tekstenViewModel.Naam),
Opmerking = HttpUtility.HtmlDecode(tekstenViewModel.Opmerking),
Waarde = HttpUtility.HtmlDecode(tekstenViewModel.Waarde),
Type_Code = tekstenViewModel.Type,
Taal_Code = tekstenViewModel.Taal,
ResourceWaarde_ID = tekstenViewModel.WAARDE_ID
};
entities.Add(resourceItem);
}
proxy.Client.CheckIfNameExists(entities, toepassingsCode);
proxy.Client.AddOrUpdateResourceItem(entities.AsEnumerable());
}
}
catch (Exception ex)
{
ModelState.AddModelError(string.Empty, ex.Message);
}
}
else
{
var errMsg = ModelState.Values
.Where(x => x.Errors.Count >= 1)
.Aggregate("Model State Errors: ", (current, err) => current + err.Errors.Select(x => x.ErrorMessage));
ModelState.AddModelError(string.Empty, errMsg);
}
resourceItems = GetResourceItemsList(new TekstenViewModel.ZoekCriteria { Taal = resourceItems.FirstOrDefault().Taal, ResourceSet_ID = resourceItems.FirstOrDefault().RESOURCE_SET_ID });
return Json(resourceItems.ToDataSourceResult(request, ModelState));
}
The problem should be that you are not returning a Json with product.ID back from your create action
Create(create => create.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Create, MVC.BeheerTeksten.Name).Data("onCreateAdditionalData"))
Need to Return , the added item with the model.Id(product => product.ID);
Kendo grid tracks the Items when created by the ID so you need to provide it back to the DataSource