Hello
We have a Listview that populates with an IEnumerable<object> The data source is set and the read called when a Kendo DropdownList.Change Event is called.
We have found that the first 1/2 the records with generate elements with data-uid, role="option" & aria-selected="false", while the latter 1/2 do not. There is no difference in the records, if we add a single record to the list at a time, it will produce the same result, the first 1/2 with, the second 1/2 without.
we are using an external template (pls see below):
<script type="text/x-kendo-tmpl" id="availableAccessRightsTemplate">
<div style="padding: 8px 0 8px 10px;letter-spacing:.2px;">
<span data-toggle="tooltip" title="#= Description#"> #= DisplayName# </span>
</div>
<hr style="margin-top: 0;margin-bottom: 0;" />
</script>
We see this behavior on 2 different ListViews, albeit on the same page with the same data types (objects).
Thanks for your help in advance
So, I've tried to get this working following many threads and articles and I can't get it to work. The value posts back to the controller fine, but I can't get it to set the default selected item on the DropDownList nor can I get it to display the text of the selected item when I select an option. If I use a client template to try and grab the text, it throws an error (Cannot read property 'Text' of null) and won't show any items in the grid. For this one, I'm not using just an IEnumerable list of ViewModels (like most of the examples show) to populate the DropDownList, I'm using a SelectList. I have it working fine in another project with an IEnumerable list of ViewModels, but I just can get it working with a SelectList and I don't want to create a ViewModel for these static options. Please help! Thanks!
Here's my grid:
@(Html.Kendo().Grid<Tracker.Areas.Admin.Models.AdHocLocationViewModel>()
.Name(
"gridAdHocLocations"
)
.Columns(columns =>
{
columns.Bound(c => c.LocationName).Title(
"Reviewer Location"
);
columns.Bound(c => c.Packet).Title(
"Added to"
);
columns.Bound(c => c.CreateDt).Title(
"Date Added"
).Width(120).Format(
"{0:MM/dd/yyyy}"
);
columns.Bound(c => c.Action).Title(
"Selection"
).ClientTemplate(
"#=Action.Text#"
).Width(180);
})
.Editable(e => e.Mode(GridEditMode.InCell))
.ToolBar(t => t.Save())
.Sortable()
.Pageable(pageable => pageable
.Refresh(
true
)
.PageSizes(
true
)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Batch(
true
)
.ServerOperation(
false
)
.Model(s =>
{
s.Id(model => model.LocationId);
s.Field(f => f.LocationName).Editable(
false
);
s.Field(f => f.Packet).Editable(
false
);
s.Field(f => f.CreateDt).Editable(
false
);
s.Field(p => p.Action).DefaultValue(
ViewData[
"defaultAction"
]
as
SelectListItem);
})
.Read(read => read.Action(
"LocationsAdHoc_Read"
,
"Location"
))
.Update(update => update.Action(
"LocationsAdHoc_Update"
,
"Location"
))
)
)
Here's my editor (I've also tried it strongly typed using DropDownListFor):
@(Html.Kendo().DropDownList()
.Name(
"Action"
)
.DataValueField(
"Value"
)
.DataTextField(
"Text"
)
.OptionLabel(
"Select Action"
)
.BindTo((SelectList)ViewData[
"actions"
])
)
Here's my model:
public
class
AdHocLocationViewModel
{
[ScaffoldColumn(
false
)]
public
int
LocationId {
get
;
set
; }
public
string
LocationName {
get
;
set
; }
public
string
Packet {
get
;
set
; }
public
int
ActionId {
get
;
set
; }
public
DateTime CreateDt {
get
;
set
; }
[UIHint(
"AdHocLocationEditor"
)]
public
SelectListItem Action {
get
;
set
; }
}
Hi,
When I'm using the export to excel function it works fine. But once I add an aggregate to the datasource as in one of the demos, I get the error attached.
Is one of my configurations wrong?
Your help will be much appreciated.
Thanks,
Waldo
My Code is as follows:
@helper TreeGrid()
{
<div>
@(Html.Kendo().TreeList<OrgStructureViewModel>()
.Name(
"treelist"
)
.Columns(columns =>
{
columns.Add().Field(e => e.Full_Name)
.FooterTemplate(
"<strong>#= count # employee(s)</strong>"
);
columns.Add().Field(e => e.Emp_No);
columns.Add().Field(e => e.Man_No).Hidden(
true
);
columns.Add().Field(e => e.Division_ID).Template(
"#= Division #"
);
columns.Add().Field(e => e.Title);
columns.Add().Command(c => { c.Edit(); c.Destroy(); }).Width(220);
})
.Toolbar(x => { x.Create(); x.Excel(); x.Pdf(); })
.Editable(x => x.Mode(
"popup"
))
.Filterable()
.ColumnMenu(
true
)
.Scrollable(
true
)
.Sortable()
.Resizable(
true
)
.Excel(excel => excel
.FileName(
"Reporting_Line.xlsx"
)
.ProxyURL(Url.Action(
"Export_Save"
,
"Reporting_Line"
))
)
.Pdf(pdf => pdf
.FileName(
"Reporting_Line.pdf"
)
.ProxyURL(Url.Action(
"Export_Save"
,
"Reporting_Line"
))
)
.Events(ev => ev.Edit(
"onEdit"
))
.DataSource(dataSource => dataSource
.Read(read => read.Action(
"Reporting_LineRead"
,
"OrgStructure"
))
.Update(update => update.Action(
"Reporting_LineEdit"
,
"OrgStructure"
))
.Create(create => create.Action(
"Reporting_LineAdd"
,
"OrgStructure"
))
.Destroy(delete => delete.Action(
"Reporting_LineDelete"
,
"OrgStructure"
))
.ServerOperation(
false
)
.Aggregates(aggr =>
{
aggr.Add(e => e.Full_Name).Count();
})
.Model(m =>
{
m.Id(f => f.Reporting_Line_ID);
m.ParentId(f => f.ReportsTo);
m.Field(f => f.Emp_No);
m.Field(f => f.Man_No);
m.Field(f => f.Division_ID);
m.Expanded(
false
);
})
)
)
}
<script type=
"text/javascript"
>
function
onEdit(e) {
console.log(e);
if
(!e.model.isNew()) {
$(
"#Emp_No"
).data(
"kendoComboBox"
).enable(
false
);
}
else
{
$(
"#Division_ID"
).data(
"kendoDropDownList"
).enable(
false
);
}
}
function
filterEmployees() {
console.log($(
"#Emp_No"
).data(
"kendoComboBox"
).value());
return
{
empNo: $(
"#Emp_No"
).data(
"kendoComboBox"
).value(),
text: $(
"#Man_No"
).data(
"kendoComboBox"
).text()
};
}
</script>
​
Hey,
I would like to pass an ID to my controller when the update event is fired on my grid. Has anyone done this before?
.Update(update => update.Action("data_update", "Home"))
public
class
ProductController : Controller
{
private
DBEntities db =
new
DBEntities ();
public
ActionResult Index()
{
ViewData[
"ProductTypes"
] = db.ProductTypes.Select(b =>
new
{ Id = b.idProductType, Name = b.ShortName });
return
View();
}
@(Html.Kendo().Grid<Data.EF.Models.Product>()
.Name(
"grid"
)
.Columns(columns =>
{
columns.Bound(c => c.Code);
columns.Bound(c => c.Color);
columns.ForeignKey(c => c.idProductType,
(System.Collections.IEnumerable)ViewData[
"ProductType"
],
"Id"
,
"Name"
).Title(
"Type"
);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(180);
})
.ToolBar(toolbar => {
toolbar.Create();
toolbar.Excel();
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Sortable(sortable => {
sortable.SortMode(GridSortMode.MultipleColumn);
})
.Filterable()
.Scrollable(scrollable => scrollable.Enabled(
false
))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.idProduct))
.Read(read => read.Action(
"KProduct_Read"
,
"Product"
))
.Create(create => create.Action(
"Product_Create"
,
"Product"
))
.Update(update => update.Action(
"Product_Update"
,
"Product"
))
.Destroy(destroy => destroy.Action(
"Product_Destroy"
,
"Product"
))
)
)
I have these model classes:
public
class
Part
{
public
Guid Id {
get
;
set
; }
string
Name {
get
;
set
; }
public
Part()
{
}
}
public
class
DetailItem
{
public
Guid Id {
get
;
set
; }
public
Part Part {
get
;
set
; }
public
DetailItem()
{
}
}
In my View, the model is the DetailItem. I am trying to use a ComboBox to select the Part for the DetailItem:
@(Html.Kendo().ComboBoxFor(model => model.Part)
.DataValueField("Id")
.DataTextField("Name")
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetParts", "RefData");
})
.ServerFiltering(true);
}
)
)
I have a grid with a large data set and I have a button that clears filters and sorting but each one causes a refresh of the data:
$(function () {
$("#reset").click(function (e) {
e.preventDefault();
var datasource = $("#grid").data("kendoGrid").dataSource;
//Clear filters:
datasource.filter([]);
//Clear sorting:
datasource.sort({});
});
});
Is there a way to combine this to only refresh the data once.
Thanks,
Erik
I've got a ComboBox which uses Grouping and I'm having trouble setting the selected item:
@(Html.Kendo().ComboBox()
.Name("GroupedList")
.Placeholder("Select...")
.DataValueField("Value")
.DataTextField("Text")
.MinLength(3)
.Filter("contains")
.HtmlAttributes(new { style = "width:100%;" })
.Height(400)
.DataSource(source => source
.Custom()
.Group(g => g.Add("GroupKey", typeof(string)))
.Transport(transport => transport
.Read(read =>
{
read.Action("GetMyItems", "MyController");
})
)
.ServerFiltering(false)
)
)
My controler is returning JSON in the following format with one of the items optionally having "Selected":true
[{"GroupKey":"Address","GroupName":"Address","Selected":false,"Text":"Correspondence Post Code","Value":"821"},...etc..]
Hi,
I'm using version 2016.1.226 and the new "Is null" and "Is not null" filters are not working correctly on DateTime columns (as well as DateTime? columns).
When I select "Is null" on a DateTime column, it seems to filter the column but the Cancel button (the X button next to filter) does not appear. Then I select "Is not null" and then "Is null" again, the Cancel button appears but it does not do anything. So the only way to get rid of the filtering is to refresh the page.
These filter operators seem to work on String columns though.
Thanks.