Hi,
I'm using an EditorTemplate to enable the user to select a person
@model Int64
@(Html.Kendo().ComboBox()
.Name("RepIRN")
.Filter("contains")
.Placeholder("Select a rep...")
.DataTextField("Text")
.DataValueField("Value")
.HtmlAttributes(new { style = "width:100%;" })
.Filter("contains")
.AutoBind(false)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetUsers", "AutoComplete");
})
.ServerFiltering(true);
})
)
The model that I'm displaying is
public class JobObjectModel
{
public long IRN { get; set; }
public string Rep { get; set; }
[UIHint("RepEditor")]
public long RepIRN { get; set; }
public string JobStatus { get; set; }
public string Promised { get; set; }
}
The combobox works fine except I can't figure out how I populate it with the rep value and rep name when the page loads the model.Everything else seems to work, if the user selects a value it is sent back to the controller fine etc.
I just can't figure out how I load the value (and text) when the page loads.
Below is how I populate the combobox
public JsonResult GetUsers(string text)
{
var sortedPeople = Database.GetPeople(text);
List<SelectListItem> items = new List<SelectListItem>();
foreach (var person in sortedPeople)
{
items .Add(new SelectListItem() { Text = person.FullName, Value = person.IRN.Value.ToString() });
}
return Json(items , JsonRequestBehavior.AllowGet);
}
Hi Team,
I have a grid with columns that has dropdownlists. I am using EditorTemplates for these dropdownlists. My concern is that I am unable to make these columns readonly on Edit. However, I am able to make the other non-dropdown columns to do the same behaviour and it works.
this is my column setup:
columns.Bound(a => a.Account).ClientTemplate("#=Account.AccountName#").Width(200);
columns.Bound(a => a.dtEffectiveDate).Width(200);
this is my editor template:
@model GlobalCommissionAndAccountAssignments.Models.AccountUpdate.AccountModel
@{
ViewBag.Title = "AccountsList";
}
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("AccountId")
.DataTextField("AccountName")
.BindTo((System.Collections.IEnumerable)ViewData["accounts"])
)
My code t o make these columns as read-only on edit:
.Events(e => e.Edit("onGridEdit"))
<script>
function onGridEdit(e) {
if (e.model.isNew() == false) {
$('input[name=dtEffectiveDate]').parent().html(e.model.dtEffectiveDate); ----> this works
$('input[name=Account]').parent().html(e.model.Account); ----> this does not work (the one using a model and client template and editor template)
}
}
</script>
Thank you in advance.
Sam
Hello All,
Let me first start by saying that I am well aware of the Drag & Drop example for Kendo UI for jQuery.
What am I looking for is an example of Drag & Drop between Kendo Grids using the ASP.NET MVC structure and syntax. Does this capability even exist in ASP.NET MVC or is it only limited to Kendo UI for jQuery?
Thanks in advance for any help regarding this question.
Best,
Will
If I put this html code in the editor and then save it:
<table>
<tr>
<td>
<p><i class="fa fa-check" style="color: green;"> </i></p>
</td>
</tr>
</table>
When I look at the HTML again it looks like this:
<table><tbody><tr><td> </td>
</tr>
</tbody></table>
It strips out the Italics tag. Normally this wouldn't be a problem but we using Font Awesome and this messes that up. I noticed that it only does this if it's in a table, if I put that same italics tag outside the table it works fine. I was able to verify this same behavior using the online demo page.
I am using Kendo UI v2018.1.221
Hi,
I've got the chart how i would like it apart form having multiple category axis, please see attached image.
As you can see i have one CategoryAxis working the persons name, ideally i'd like each Column name to appear above that.(series.stack)
Here's my current code:
@(Html.Kendo().Chart()
.Name(
"chart"
)
.Title(
"Project Management"
)
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
)
.SeriesDefaults(seriesDefaults =>
seriesDefaults.Column().Stack(
true
)
)
.Series(series =>
{
foreach
(var def
in
Model.Series)
{
series.Column(def.Data).Name(def.Name).Stack(def.Stack);
}
})
.SeriesColors(Colours.Blue, Colours.Orange, Colours.Grey, Colours.Yellow, Colours.LightBlue, Colours.Green)
// This should be the Stack Name (Overhead)
.CategoryAxis(axis => axis.Labels(l => l.Rotation(90).Template(
"#= series.stack #"
)))
// This should be the Persons Name (FullName)
.CategoryAxis(axis => axis.Categories(Model.Categories))
.Tooltip(tooltip => tooltip
.Visible(
true
)
.Template(
"#= series.name #: #= kendo.format('{0:N2}', value) #"
)
)
)
What's the easiest way to achieve this? This is based off of your example project: https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/chart/dynamic-series
Thanks,
Lee.
Hi,
I have a view with a text box , button and two grids. The intention is to populate the two grids with data, when the text box is supplied with a string value and the button is clicked. Since, kendo().TextBox() does not support Events, I have introduced the button which when clicked updates both the grids as below:
$("#get").click(function () {
var value = $("#customerInfo").data("kendoTextBox");
$("#gridCurrent").data("kendoGrid").dataSource.read();
$("#gridAll").data("kendoGrid").dataSource.read();
});
This works fine. However after the grids are loaded, I am unable to add a new record to the grid, the Add New Record button on the grid does not work. Any suggestions on this?
Note: I had to use a text box because, the input value is a alphanumeric (varying size) and I found no suitable component.
Thank you in advance.
Sam
I have a listbox pair, and I am removing an item or items from one and transferring them to the other. Some code is executed when this is done.
The problem is that the ListBox selects an item in the list when the transfer is done, and this is not what I want it to do.
I have tried to use javascript to unselect all items in the list to no avail.
<
div
style
=
"width:100%;"
>
<
div
style
=
"width:50%;float:left;"
>
@(
Html.Kendo()
.ListBox()
.Name("NotReviewers")
.DataTextField("FullName")
.DataValueField("user_name")
.TemplateId("itemTemplate")
.ConnectWith("Reviewers")
.HtmlAttributes(new { style = "width:100%;" })
.Selectable(ListBoxSelectable.Multiple)
.Toolbar(toolbar =>
{
toolbar.Position(Kendo.Mvc.UI.Fluent.ListBoxToolbarPosition.Right);
toolbar.Tools(
tools => tools
.Remove()
.TransferAllFrom()
.TransferAllTo()
.TransferFrom()
.TransferTo()
);
}
)
.BindTo((System.Collections.IEnumerable)ViewBag.nonreviewers)
)
</
div
>
<
div
style
=
"width:50%;float:right;"
>
@(
Html.Kendo()
.ListBox()
.HtmlAttributes(new { style = "width:100%;" })
.Name("Reviewers")
.Events( events=>{
events.Add("AddReviewer");
events.Remove("RemoveReviewer");
}
)
.TemplateId("itemTemplate")
.DataTextField("FullName")
.DataValueField("user_name")
.ConnectWith("NotReviewers")
.Selectable(ListBoxSelectable.Multiple)
.BindTo((System.Collections.IEnumerable)ViewBag.reviewers)
)
</
div
>
</
div
>
I use the following javascript to handle the transfer:
function AddReviewer(e)
{
var dataItems = e.dataItems;
var url = window.location.href.replace("Requestors", "AddRequestor");
if (dataItems.length > 0) {
for (var i = 0; i < dataItems.length; i++) {
var dataItem = dataItems[i];
$.ajax({
url: url,
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ user_name: dataItem.user_name }),
async: false,
processData: false,
cache: false,
error: function (xhr) {
}
});
}
}
var reviewers = document.getElementById("Reviewers");
for ( i = 0; i < reviewers.options.length; i++) {
reviewers.options[i].selected = false;
}
var notreviewers = document.getElementById("NotReviewers");
for (i = 0; i < notreviewers.options.length; i++) {
notreviewers.options[i].selected = false;
}
reviewers.value = "";
notreviewers.value = "";
reviewers.selectedIndex = -1;
notreviewers.selectedIndex = -1;
reviewers.blur();
notreviewers.blur();
return true;
}
None of the section of the code that I am using to remove the selection works.
The other javascript callback works in a similar manner.
Does anyone have any suggestions on how to remove the selection from the listbox once the work is done?