Kendo editor doesn't work with html - html

I have a Kendo Grid in my application
#(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.Naam).Width(125).ClientTemplate("<div id='editorDiv'><div class='input'>#=Naam#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, htmlAttributes: new { onclick = "openPopupDemo('#: Naam #', '#: ID #', 'Naam')" }));
columns.Bound(product => product.Waarde).Width(125).ClientTemplate("<div id='editorDiv'><div class='input'>#=Waarde#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, htmlAttributes: new { onclick = "openPopupDemo('#: Waarde #', '#: ID #', 'Waarde')" }));
columns.Bound(product => product.Opmerking).Width(250).ClientTemplate("<div id='editorDiv'><div class='input'>#=Opmerking#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, 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"))
.Groupable()
.Navigatable()
.Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.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_CreateUpdate, MVC.BeheerTeksten.Name))
.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_CreateUpdate, MVC.BeheerTeksten.Name))
.Destroy(destroy => destroy.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Delete, MVC.BeheerTeksten.Name))
)
)
Here's s pic of it.
When I click in a dotted button, it opens a Kendo editor with the value of the selected cell. So far, so god
If I do formatting to the text and save it, the next time I try to edit it, the editor won't open. Instead, the text will be edited in the default input.
Doing a simple formatting like
<strong><em>Carolina</em></strong>
will still allow me to open the editor, but if I underline the text, for example,
<strong><em><span style="text-decoration:underline;">Carolina</span></em></strong>
the editor won't work and the text will be edited in the default input.
If I format the text with Heading h1, for example, after removing the underline, off course, the editor will work, but the text in the default input will have a scrollbar.
This only happens with formatted text. Any ideas??

Related

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.

Newly added row gets disappear in kendo grid

I have a kendo grid and a AddRow button.On AddRow Button click I am adding a new row to kendo grid.When I click on AddRow button, new row gets added sucessfully but clicking anywhere else in the page except first column of newly added row,row disappears.Here is my code on button click:
$('#AddRow').click(function () {
grid = $('#grdclaimantTypeTips').data("kendoGrid");
grid.addRow();
row = grid.tbody.find(".k-grid-edit-row");
grid.select(row);
}
Here is my code for kendo grid:
#(Html.Kendo().Grid<ClaimPro.Data.ClientAttributeDO>()
.Name("grdclaimantTypeTips")
.Columns(columns =>
{
columns.Bound(Type => Type.claim_type_name).Title(Resource.ClaimType).Width(80).EditorTemplateName("ClientAttributesDDL").EditorViewData(new { columnName = "claim_type_cd" });
columns.Bound(Type => Type.claimant_name).Title(Resource.Claimant).Width(120).ClientTemplate("#=claimant_name_changed#");
columns.Bound(Type => Type.tip).Title(Resource.Tip).Width(200).HtmlAttributes(new { #class = "Wrap" });
columns.Bound(Type => Type.tip).Hidden();
columns.Bound(Type => Type.tip).Hidden();
columns.Bound(Type => Type.id).Hidden();
})
.Scrollable()
.Sortable()
.Filterable()
.Selectable(selectable =>
{
selectable.Mode(GridSelectionMode.Single);
selectable.Type(GridSelectionType.Row);
}
)
.Pageable(pageable => pageable.Input(true).PageSizes((int[])ViewData["DefaultDropdownSize"]))
.Resizable(resize => resize.Columns(true))
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Events(e => e.Edit("onEditGrid"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Batch(true)
.Model(model => model.Id(c => c.id))
.Model(model => model.Field(p => p.claimant_name).Editable(false))
.Read(read => read.Action("GetClaimantTypeDetails", "ClientAttribute"))
)
)

Column with menu in each cell with menu items

I want to create a menu item in each cell using Kendo Grid MVC I have managed to get the grid to display with the menu item in each cell but when I click on the menu I don't see the menu items.
Need the menu items to show in their own column this is why I have not bound it to a specific property.
Any ideas on what I'm doing wrong?
#(Html.Kendo().Grid(Model)
.Name("gridDropDownMenu")
.Columns(columns =>
{
columns.Template(#<text></text>).Title("").Width(120).HtmlAttributes(new { #class = "templateCell" }).ClientTemplate(
Html.Kendo().Menu()
.Name("menu_#=ProductID#")
.Items(its =>
{
its.Add().Text("Actions").Items(nested =>
{
nested.Add().Text("Test 1");
nested.Add().Text("Test 2");
});
})
.ToClientTemplate().ToHtmlString()
);
columns.Bound(p => p.ProductName);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Scrollable()
.HtmlAttributes(new { style = "height:250px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(20)
.ServerOperation(false)
.Events(events => events.Error("errorHandler"))
.Model(model =>
{
model.Id(p => p.ProductID);
//model.Field(p => p.ProductID).Editable(true);
model.Field(p => p.CategoryID).DefaultValue(1);
})
.Read(read => read.Action("ForeignKeyColumn_Read", "Home"))
.Update(update => update.Action("ForeignKeyColumn_Update", "Home"))
.Create(create => create.Action("ForeignKeyColumn_Create", "Home"))
.Destroy(destroy => destroy.Action("ForeignKeyColumn_Destroy", "Home"))
)
)
Resolved by adding the following: .Events(ev => ev.DataBound("initMenus"))
function initMenus(e) {
$(".templateCell").each(function(){
eval($(this).children("script").last().html());
});
}

Disable kendo editor in one column of a Kendo grid

I have this kendo grid
#(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.Naam).Width(125).ClientTemplate("<div id='editorDiv'><div class='input'>#=Naam#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, htmlAttributes: new { onclick = "openPopupDemo('#: Naam #', '#: ID #', 'Naam')" }));
columns.Bound(product => product.Waarde).Width(125).ClientTemplate("<div id='editorDiv'><div class='input'>#=Waarde#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, htmlAttributes: new { onclick = "openPopupDemo('#: Waarde #', '#: ID #', 'Waarde')" }));
columns.Bound(product => product.Opmerking).Width(250).ClientTemplate("<div id='editorDiv'><div class='input'>#=Opmerking#</div><div class='editor'>" +
Html.WebCore().LinkButton(type: ButtonType.MeerActies, 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"))
.Groupable()
.Navigatable()
.Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.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_CreateUpdate, MVC.BeheerTeksten.Name))
.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_CreateUpdate, MVC.BeheerTeksten.Name))
.Destroy(destroy => destroy.Action(MVC.BeheerTeksten.ActionNames.ResourceItems_Delete, MVC.BeheerTeksten.Name))
)
)
#Html.WebCore().Popup.Remove("confirmResourceItemPopup", "Verwijderen resource item", "")
Here is a picture of the grid
The dotted buttons open a Kendo Editor.
I am using Claims Authentication in my project. I have ReadOnly and Administrator permissions. If you have ReadOnly permissions, the editor is disabled.
This is my editor.
#Html.WebCore().Popup.CustomButtons("popupDemo", "Waarde", Html.Kendo().Editor().Name("waardeEditor").HtmlAttributes(new { #class = "editorStyle" }).Tools(tools => tools
.Clear()
.Bold().Italic().Underline().Strikethrough()
.JustifyLeft().JustifyCenter().JustifyRight().JustifyFull()
.InsertUnorderedList().InsertOrderedList()
.Outdent().Indent()
.CreateLink().Unlink()
.InsertImage()
.SubScript()
.SuperScript()
.TableEditing()
.ViewHtml()
.Formatting()
.FontName()
.FontSize()
.FontColor().BackColor()
).ToHtmlString(), new[]{new PopupButton("popupDemoAnnuleren", "Cancel", false),new PopupButton("popupDemoOk", "OK")})
And this is the code to disable it when ReadOnly is true.
$(document).ready(function () {
if ('#Html.Raw(Json.Encode(Model.ReadOnly))' == "true") {
$("#waardeEditor").data("kendoEditor").body.contentEditable = false;
}
});
So, what this does is disable editing in the editor, no matter which button you click.
Now, I do have a situation where a user has more than ReadOnly permissions, but is not Administrator either. That means he can edit and save only the Waarde column.
I do have a way of disabling the buttons in the other columns, but the requirements of my application specify that the user should be able to open the content of cells in Naam and Opmerking columns in the editor, but not be able to edit it and that they should be able to open and edit the contents of Waarde columns.
And this is where I'm stuck. I can't figure out a way to disable the editor in all columns, except when you click any button in the Waarde column.
I did it. It was simpler than I thought. I used the onPopupDemo method that I used to open the editor.
here's the code.
var selectedGridRowID = 0;
var selectedGridColumnName;
function openPopupDemo(gridCellContent, gridIdentifier, columnIdentifier) {
var editor = $("#waardeEditor").data("kendoEditor")
if ('#Html.Raw(Json.Encode(Model.ReadOnly))' == "false" && '#Html.Raw(Json.Encode(Model.Administrator))' == "false" && columnIdentifier != "Waarde") {
editor.value(gridCellContent)
editor.body.contentEditable = false;
}
else {
editor.value(gridCellContent)
editor.body.contentEditable = true;
}
domain.WebCore.popup.show("popupDemo");
selectedGridRowID = gridIdentifier;
selectedGridColumnName = columnIdentifier;
};

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