Good day. This must be a very basic thing to do, though I didn't manage to find any information on it.
I have a treeview setup like this:
@(
Html.Kendo().TreeView()
.Name("treeview")
.DataTextField("Text")
.DataSource(dataSource => dataSource.Read(read => read.Action("GetView", "Tree"))
)
My controller looks like this:
public
class
TreeController : Controller
{
private
readonly
IRepository _repository;
public
TreeController(IRepository repository)
{
_repository = repository;
}
[HttpGet]
public
JsonResult GetView()
{
var items = _repository.GetItems();
var viewmodel = items.Select(t =>
new
{
id = t.Id,
Text = t.Text,
hasChildren = t.HasChildren
});
return
Json(viewmodel, JsonRequestBehavior.AllowGet);
}
}
That part works just fine.
Now, I would like to add a button that would, say, rename the selected item. So,I know how to get the selected item in the treeview. What I do not know how to implement is the connection viewmodel -> data model. That is, knowing the selected html item I have no idea how to get the model item it coresponds to. That would be solvable if I could add my custom html "model-id" property on every item and pass it back to controller on my button click. Which I have no idea how to implement either.
Thank you in advance.
Is there a way to localize the optionlabel text a bit like that:
....
.OptionLabel(@Localizer["MyLocalizedOptionLabel"].Value)
....
Thanks
I'm using a grid with a popup editor and use bootstrap layout.
I have done the right styling override but the right margin is not there. Any suggestions.
In the Razor view of the grid
<style>
.k-edit-form-container {
width
:
auto
;
padding
:
10px
;
}
.k-edit-form-container div {
box-sizing: border-box;
}
</style>
In the popup editor
<
div
class
=
"row"
>
<
div
class
=
"col-md-3"
>
<
div
class
=
"form-group form-group-sm"
>
<
label
asp-for
=
"NAME_RES"
class
=
"control-label"
></
label
>
<
div
>
<
input
asp-for
=
"NAME_RES"
class
=
"form-control"
/>
<
span
asp-validation-for
=
"NAME_RES"
class
=
"text-danger"
/>
</
div
>
</
div
>
</
div
>
<
div
class
=
"col-md-3"
>
<
div
class
=
"form-group form-group-sm"
>
<
label
asp-for
=
"TYPE_RES"
class
=
"control-label"
></
label
>
<
div
>
<
select
asp-for
=
"TYPE_RES"
asp-items=@ViewBag.arType
class
=
"form-control"
></
select
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"col-md-3"
>
<
div
class
=
"form-group form-group-sm"
>
<
label
asp-for
=
"ROLE_RES"
class
=
"control-label"
></
label
>
<
div
>
<
select
asp-for
=
"ROLE_RES"
asp-items=@ViewBag.arRole
class
=
"form-control"
></
select
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"col-md-3"
>
<
div
class
=
"form-group form-group-sm"
>
<
label
asp-for
=
"IDENTNUMBER_RES"
class
=
"control-label"
></
label
>
<
div
>
<
input
asp-for
=
"IDENTNUMBER_RES"
class
=
"form-control"
/>
<
span
asp-validation-for
=
"IDENTNUMBER_RES"
class
=
"text-danger"
/>
</
div
>
</
div
>
</
div
>
</
div
>
Thanks
Is there a way to localize field in the popup editor of a grid.
I've try to use the legacy way but it does not work.
I've tried using appropriate resource file
...
@inject IViewLocalizer Localizer
@using Microsoft.AspNetCore.Mvc.Localization
...
<
div
>
<
label
class
=
"control-label"
>@Localizer["idsResidents"]</
label
>
</
div
>
Or
...
@inject IViewLocalizer Localizer
@using Microsoft.AspNetCore.Mvc.Localization
...
<
div
>
<
label
class
=
"control-label"
>@Localizer["idsResidents"].Value</
label
>
</
div
>
I have a ClientDetailsTemplate where the details grid contains InCell editing. I have added the Toolbar Create and Save buttons to the grid, but I'd like to add a title to the toolbar to the left of the buttons.
Example:
Sub-Departments [ Save Changes ] [ Cancel Changes ] [ Add New record ]
I tried using the Toolbar.Template which gave me the title, but I lost the buttons.
What is the best way to achieve this? If I need to use the Template, how to I get the 3 buttons included into the template along with the Title text?
Thanks,
Shawn
I have an inline grid, containing cascading foreign key drowdownlists with custom templates.
When selected value of one of the dropdownlist changes, I have to change the selected value of another foreign key dropdownlist within the grid.
I have subscribed to both Change and Select events of the source dropdownlist. Change event is working correctly. However Change event is also fired at initial load of the dropdownlist since the existing value of the foreign key is assigned to the dropdownlist. This isn't suitable for my scenario, since I want to get the event only when user manually changes the selection of the dropdownlist.
When I subscribe to Select Event, the event firing timing is exactly as I expect. It is only fired, when user manually changes the selection. However, the selected item's Text and Value properties are returned as "Undefined". I am accessing the properties as in the dropdownlist demo.
function onVehicleSelect(e) {
if (e.item) {
var dataItem = e.dataItem(e.item);
console.log("event :: select (" + dataItem.Text + " : " + dataItem.Value + ")");
}
}
I am stuck in this problem since long time. Urgent help would be appreciated.
Hi,
I would like to know if we can have a sort of foreign key mechanism in the Group method of the DropDownlist.
My goal is to group the item using a PrimaryKey (that is an Id of my records) but displaying the value of the record instead
of the Id in the label of the group displayed when the Dropdownlist is expanded.
Thanks.