Hi, I'm trying to use server-side wrappers of the UI Spreadsheet for ASP.NET MVC. I've looked over the documentation and searched this forum, and I can't find the answer to this question: is it possible to bind the spreadsheet data to a model passed to a view, in the same manner as it's done for the Grid control? For example, like the below.
Thank you!
example below;
@(Html.Kendo().Grid(Model) //Bind the Grid to the Model property of the view.
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductID); //Create a column bound to the "ProductID" property
columns.Bound(p => p.ProductName); //Create a column bound to the "ProductName" property
columns.Bound(p => p.UnitPrice); //Create a column bound to the "UnitPrice" property
columns.Bound(p => p.UnitsInStock);//Create a column bound to the "UnitsInStock" property
})
.Pageable() //Enable paging.
)
Hello Telerik,
We are using kendo controls for over the past 5 years, and we have recently noticed a bug with the hierarchy grid's child's which contain date columns and filters. We always initialize detail grids on detailnit of master grid, by passing the data which is rendered as a list from master model.
So, to give you an example. Imagine we have a master grid defined like below :
01.
@(Html.AthenaParameterConfigGrid<StudentItineraryResult>()
02.
.Name(
"studentItinerary"
)
03.
.Columns(columns =>
04.
{
05.
columns.Bound(e => e.Person.Id).Hidden();
06.
08.
columns.Bound(e => e.Person.FathersName).Width(200);
09.
columns.Bound(e => e.Person.MothersName).Width(200);
10.
columns.Bound(e => e.Person.Email).Width(200);
11.
23
24.
})
25.
.Scrollable(s => s.Enabled(
true
).Height(
"auto"
))
26.
.Sortable()
27.
.Groupable(gr => gr.Enabled(
false
))
28.
.HtmlAttributes(
new
{ @
class
=
"hide-vertical-scrollbar atn-tabstrip-grid atn-grid-dropdown-menu"
})
29.
.ClientDetailTemplateId(
"itineraries"
)
30.
.AutoBind(
false
)
31.
.DataSource(dataSource => dataSource
32.
.Ajax()
33.
.PageSize(10)
34.
.ServerOperation(
false
)
35.
.Model(model => model.Id(p => p.StudentId))
36.
.Read(read => read.Action(
"StudentItinerariesSearch"
,
"Student"
).Data(
"athena.studentItineraries.searchRequestData"
))
37.
.Events(events => events
38.
.Error(
"athena.utilities.onErrorSearch"
).RequestEnd(
"athena.utilities.laddaStop"
)
39.
)
40.
)
41.
.Events(events => events.DetailInit(
"athena.studentItineraries.detailInit"
))
42.
.Deferred())
And a detail template grid initialized again server side with no datasource read options configured, where BusStopArrivalTime and AtttendeeEventDate(and other fields that we dont show in this case) are proper DateTime fields.<script id=
"itineraries"
type=
"text/kendo-tmpl"
>
@(Html.Kendo().TabStrip()
.Name(
"tabStrip_#=StudentId#"
)
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text(@Html.GetResource(common,
"TabStripBasic"
)).Content(@<text>
@(Html.AthenaParameterConfigGrid<StudentItineraryFlat>()
.Name(
"grid_#=StudentId#"
)
.Columns(columns =>
{
columns.Bound(o => o.BusStopLabel).Hidden();
columns.Bound(o => o.BusRouteLabel).Width(250);
columns.Bound(o => o.BusStopName).Width(100);
columns.Bound(o => o.AttendeeStatusUserString).Width(80);
// TODO : filtering here does not want to work...
columns.Bound(o => o.BusStopArrivalTime).Width(80).ClientTemplate(
"\\#= BusStopArrivalTime !=null ? kendo.toString(kendo.parseDate(BusStopArrivalTime), 't') : '' \\#"
).Filterable(filterable => filterable.UI(GridFilterUIRole.TimePicker));
// TODO : filtering here does not want to work...
columns.Bound(o => o.AttendeeEventDate).Width(80).ClientTemplate(
"\\#= AttendeeEventDate !=null ? kendo.toString(kendo.parseDate(AttendeeEventDate), 'd') : '' \\#"
).Filterable(filterable => filterable.UI(GridFilterUIRole.DatePicker));
columns.Bound(o => o.AttendeeCronLabel).Width(100);
columns.Bound(o => o.AttendeeComment).Width(150);
columns.Bound(o => o.ProfileOuSpecialtySemesterLabel).Width(200);
})
.AutoBind(
false
)
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.ServerOperation(
false
)
.Model(model =>
{
model.Id(c => c.AttendeeId);
})
)
.Events(ev => ev.DataBinding(
"athena.studentItineraries.childDataBinding"
).DataBound(
"athena.studentItineraries.childDataBound"
))
.Sortable(x => x.Enabled(
true
))
.Filterable(x => x.Enabled(
true
))
.Pageable(pgb => pgb.Enabled(
false
))
.Groupable(gr => gr.Enabled(
false
))
.ToClientTemplate())
</text>
);
}).Deferred()
.ToClientTemplate()
)
</script>
So, in the detailInit of the master grid, we take the data from sender event(master grid), and we fill child's grid dataSource.data with this list of data like below:
function
detailInit(e) {
var
grid = $(
"#grid_"
+ e.data.StudentId).data(
"kendoGrid"
);
if
(e.data.HasAttendee) {
// feed child grid with master data;
grid.dataSource.data(e.data.ItinerariesFlattened.toJSON());
}
}
So the problem here is, that our datetime fields as described above, are not working. After a bit research, i found that e.data.ItinerariesFlattened or e.data.ItinerariesFlattened.toJSON(), if i log the data to console i have an object like this
....
//other string fields
BusRouteEndDate:
"/Date(1561237200000)/"
,
BusRouteStartDate:
"/Date(1538341200000)/"
BusStopArrivalTime:
"/Date(1554784800000)/"
...
//other string fields here
function
detailInit(e) {
var
grid = $(
"#grid_"
+ e.data.StudentId).data(
"kendoGrid"
);
if
(e.data.HasAttendee) {
// feed child grid with master data;
var
parsedData = e.data.ItinerariesFlattened.map(
attendee => {
var
model = attendee || {};
model.AttendeeEventDate = w.kendo.parseDate(attendee.AttendeeEventDate);
model.BusStopArrivalTime = w.kendo.parseDate(attendee.BusStopArrivalTime);
return
model;
}
);
grid.dataSource.data(parsedData);
}
}
Hello, I'm having troubles after update with the pagination controls in the grids.
The "k-pager-nav" controls are getting duplicated and the buttons to the right and to the left of the pagination numbers are blocked. The ones that works are the second button group.
Here is an image of the grid pagination with the duplicated controls.
Thank you!
I have a listBox that I can manually sort using the toolbar buttons. The ListBox is in a form, so when I submit a form, the items in that list box get submitted as an int array. However, regardless of how I sort the ListBox, the array of items is always in the same order. I assume that, as there is functionality to interactively sort a list box, there is a method to get that sequence out. I can't find an example of how this might be achieved in the context of a listbox in a form. Could you provide some pointers? Thanks.
Ian Parsons.
I'm trying to set up a MultiSelectFor to be used NoDataTemplate, but the pop-up just never seems to appear. There is an HTML5 version on the site,but not one for MVC: http://demos.telerik.com/kendo-ui/multiselect/addnewitem
Here is what I have wrriten, but the template never appears
<
script
id
=
"@noDataTemplateID"
type
=
"text/x-kendo-tmpl"
>
<
div
>
No data found. Do you want to add new item - '#: instance.input.val() #' ?
</
div
>
<
br
/>
<
button
class
=
"k-button"
onclick
=
"addNew('#: instance.element[0].id #', '#: instance.input.val() #')"
>Add new item</
button
>
</
script
>
<
script
>
//the actual data won't get synced to the server, but that's okay because when we save this new item on the update of the parent model, we presumably will grab that newly added item on the next read
function addNew(widgetId, value) {
var widget = $("#" + widgetId).getKendoMultiSelect();
var dataSource = widget.dataSource;
if (confirm("Are you sure?")) {
dataSource.add({
ProductID: 0,
ProductName: value
});
dataSource.one("requestEnd", function (args) {
if (args.type !== "create") {
return;
}
var newValue = args.response[0].ProductID;
dataSource.one("sync", function () {
widget.value(widget.value().concat([newValue]));
});
});
dataSource.sync();
}
}
</
script
>
@(
Html.Kendo().MultiSelectFor(m => m)
.DataTextField(descriptionField)
.DataValueField(IDFIeld)
.NoDataTemplate(noDataTemplateID)
.DataSource(source =>
{
source.Read(read => {
read.Action("Read", "List", new { ListType = ListType, Param1 = Param1, Param2 = Param2, Param3 = Param3 });
})
.ServerFiltering(true);
})
)
Anyone know why I'm getting a javascript error saying: "Kendo file / is included more than once"? Sometimes it doesn't show this error, but most of the time it does. Below is my layout.cshtml. Any help would be greatly appreciated!
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2017.1.223/kendo.common.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2017.1.223/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2017.1.223/kendo.default.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2017.1.223/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/kendo/2017.1.223/jquery.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2017.1.223/jszip.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2017.1.223/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2017.1.223/kendo.aspnetmvc.min.js")"></script>
@RenderSection("HeadContent", false)
@*using the bundles instead*@
@*@Styles.Render("~/Content/test.css")*@
@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/Content/css")
<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
</head>
<body>
<header>
</header>
<div id="body">
@RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
@RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
</div>
</footer>
</body>
</html>
<!--Reference the SignalR library. (after jquery references)-->
<script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="~/signalr/hubs"></script>
Hi,
I'm evaluating the grid with the trial version to see if your solution fits into our web application.
I'm trying to adapt the grid in our web asp.net MVC and I've encountered a problem with the filters date.
We need to enter "> = 1.1.2018" or "1.1.2018#31/12/2018" and it reaches FileDescriptor request as a value. With this i build the query to launch the SQL server.
Now no Filters arrive to request from ajax "Consulta_Viajes"
@(Html.Kendo().Grid<ViewModels.ViajesViewModel>()
.Name(
"grid"
)
.EnableCustomBinding(
true
)
.Columns(columns =>
{columns.Bound(c => c.itdavia).Hidden();
columns.Bound(c => c.ctdavia).Title(LocalizationResources.Strings.viaje);
columns.Bound(c => c.ctrnest).Title(LocalizationResources.Strings.codigo_estado);
columns.Bound(c => c.dtrnest).Title(LocalizationResources.Strings.estado);
columns.Bound(c => c.ftdavia).Title(LocalizationResources.Strings.fecha_viaje).Groupable(
false
).Format(
"{0:dd/MM/yyyy}"
).Width(150);
columns.Bound(c => c.htdavia).Title(LocalizationResources.Strings.hora_viaje).Groupable(
false
).Format(
"{0:HH:mm}"
);
columns.Bound(c => c.cdvn).Title(LocalizationResources.Strings.codigo_division);
})
.Scrollable()
.Groupable()
.Sortable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row)
.Extra(
false
))
.Pageable()
.Resizable(resize => resize.Columns(
true
))
.Reorderable(reorder => reorder.Columns(
true
))
.DataSource(dataSource => dataSource
.Ajax()
.Read(
"Consulta_Viajes"
,
"AsignacionMensajero"
,
new
{ strTabla =
"tdavia"
})
.ServerOperation(
true
)
)
.Deferred(
true
)
.AutoBind(
false
))
How can I do this?
Thanks in advance.
Regards.
Hi,
In our app we have a js frunction to prevent the autocomplete of inputs and textboxes:
function autoCompleteOff() {
$(':text, form').attr('autocomplete', 'nope');
}
The function it's loaded when the app starts so that be executed in every form we have.
The problem that we have is that when we open a kendo window the function it's not working and the text boxes show possible options to select.
We would like know how to load this function and prevent these suggestions.
We could add a call in each window but it does not seem like the best option. We believe that it should be defined only once. Any idea how to fix it?
Thanks in advance.
Hello,
I have a requirement to alter the 'Year' view to have 3 months per row which would make it 4 rows of 3 months. Is this something that is currently possible to achieve?
Thank you
Lucy
Hi,
My co-worker sent a excel file to me he just created. I can
open it by double clicked file in the folder. But when I try to use Kendo Ul
Upload control to select it I got " You don't have permission to open this
file. Contact file owner or administrator to obtain permission". My co-worker said he didn't do any special thing
for this file. I checked property - security tab. It same as another file which I could select it. Could anyone help the
issue?
Thanks in advance!