Telerik Forums
UI for ASP.NET MVC Forum
1 answer
210 views

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.

Joana
Telerik team
 answered on 16 Feb 2017
3 answers
232 views

Is there a way to localize the optionlabel text a bit like that:

....

  .OptionLabel(@Localizer["MyLocalizedOptionLabel"].Value)

....

Thanks

Nencho
Telerik team
 answered on 16 Feb 2017
3 answers
331 views

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

 

Konstantin Dikov
Telerik team
 answered on 16 Feb 2017
1 answer
133 views

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>
Stefan
Telerik team
 answered on 16 Feb 2017
10 answers
880 views
Could you provide a sample of how to get the data item for a row?
Carlos
Top achievements
Rank 1
 answered on 15 Feb 2017
1 answer
892 views
I have a grid setup to show a popup editor for creating items.  The problem I am running into is that depending on what the user selects in the popup editor, the code might create more than one item.  The controller method is returning all of the created items but only the first one gets added to the grid.  How do I either a) get the grid to show all of my added items or b) refresh the grid?  I can't just reload the page because there are other items on that page that I don't want to reload.
Stefan
Telerik team
 answered on 15 Feb 2017
6 answers
2.3K+ views

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

Shawn
Top achievements
Rank 1
 answered on 14 Feb 2017
1 answer
4.0K+ views

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.

 

Konstantin Dikov
Telerik team
 answered on 14 Feb 2017
2 answers
114 views

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.

Michel
Top achievements
Rank 1
 answered on 14 Feb 2017
1 answer
60 views
When I load data into a grid via a DataSourceRequest based Read action, I would like a column to always show a dropdown.  As it stands currently, in my limited experience, you either have to double click a row for InCell editing or click an Edit button for the PopUp editor, all interaction with the DataSourceRequest based Update action.  But I don't want my users to have to clikc a button, nor double click a row.  How can I show a dropdown in a specific column, for all rows without having to activate an edit mode?  Is it possible?  And I assume, I would have to use the Batch mode?
Konstantin Dikov
Telerik team
 answered on 14 Feb 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?