Hi,
I have tried the "work around" for creating a separate datasource on a filterable column in a grid but I'm getting an HTTP 500 response when I execute it. My controller code is executed but all I see when the filter dialog box opens is a spinning wheel...
Here is the link to the "work around": https://docs.telerik.com/kendo-ui/knowledge-base/sort-multi-check-filter-mvc-grid
My filterable grid column code:
columns.Bound(c => c.WallThickness).Format("{0:0.000}").Filterable(ftb =>
{
ftb.Multi(true);
ftb.DataSource(ds => ds
.Custom()
.Type("Json")
.Transport(t => t.Read("SortWallThickness", "Materials"))
.Schema(s => s
.Data("Data"))
.Sort(sort => { sort.Add("WallThickness").Ascending();
})
);
})
My controller code:
public ActionResult SortWallThickness([DataSourceRequest] DataSourceRequest request)
{
List<string> data = WeldObject.GetWT(0);
return Json(new[] { data }.ToDataSourceResult(request, ModelState));
}
Appreciate your help,
Carolyn
I have a simple grid and want to have a dropdown filter for the column Project. I do not want to make a separate call to get data for this dropdown. Can I use the unique values from the grid to populate the filter?
@(Html.Kendo().Grid(Model)
.Name("ByProjectAndReviewerGrid")
.Deferred(true)
.ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("ByProjectAndReviewer.xlsx")
.AllPages(true)
)
//.Events(events => events.DataBound("databound"))
.Columns(columns =>
{
columns.Bound(p => p.Project).Title("Project").Width(400);
columns.Bound(p => p.Reviewer).Title("Reviewer").Width(300);
columns.Bound(p => p.ReleasePercent).Title("Release %").Filterable(false).Width(150);
columns.Bound(p => p.DoNotReleasePercent).Title("Do Not Release %").Filterable(false).Width(150);
columns.Bound(p => p.RejectPercent).Title("Reject %").Filterable(false).Width(150);
columns.Bound(p => p.Release).Title("Release").Filterable(false).Width(150);
columns.Bound(p => p.DoNotRelease).Title("Do Not Release").Filterable(false).Width(150);
columns.Bound(p => p.Reject).Title("Reject").Filterable(false).Width(150);
columns.Bound(p => p.TotalReviewed).Title("Total Reviewed").Filterable(false).Width(150);
})
.HtmlAttributes(new { style = "height: 650px;" })
.NoRecords()
.AutoBind(false)
.Sortable()
.Filterable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("ByProjectAndReviewer_Read", "Reporting"))
)
)
I'm using the asp.net MVC Grid with inline edit. I have a foreign key column with a editor template. When adding a new record (via a modal - partial view).
I have a situation where I can add numerous records using the modal. Each record can reference another already created record from the same table.
The grid refreshes with each newly created record however the field that references a previous record shows blank when the record being referenced is a newly created record. The field in the grid is populated via the model.
I think the issue i'm having is that the model is not being updated when creating new records, so those new records that reference newly created records themselves show a blank in the field. If i refresh the page then the field shows the values OK.
My Editor template is using a Kendo Drop Down List using Datasource to reference a Read Action and this is populated as expected when going into edit mode. If I select a newly created record with a blank field the drop down will have the correct value pre-selected but this is not shown on the grid.
I have seen forum answers where the controller method used in my Editor Template returns the collection for the drop down list and the view with its collection updated however making this change stops the drop down working.
So the question is whether there is a simple way of updating the grid collection so that i dont get blank records when adding new data
I've got a view with a Html.TelerikReporting().ReportViewer() mvc helper.
in a partial view I load a Html.Kendo().Grid<FFDashboardWeb.Models.PDocDashboardGridViewModel>()
if I enable any paging features on the grid, I get javascript errors when it executes the datasource read event . The javascript is breaking in the =report viewer= javascript file! It's like the report viewer is intercepting the datasource callback?
If I remove the report viewer from the page, the grid works fine.
@(Html.Kendo().Grid<FFDashboardWeb.Models.PDocDashboardGridViewModel>()
.Name("documentDetail")
.Columns(columns =>
{
columns.Bound(m => m.Id).Hidden().Title("Date Scanned").Width(150).Format("{0:d}");
columns.Bound(m => m.TransactionDate).Title("Date Scanned").Width(150).Format("{0:d}");
columns.Bound(m => m.Result).Title("Result").Width(150);
columns.Bound(m => m.DocumentClassName).Title("Document").Width(400);
columns.Bound(m => m.IssuingStateName).Title("State").Width(150);
columns.Bound(m => m.AlertsJoined).Title("Alerts");
})
.Pageable()
.Sortable(sortable =>
{
sortable.SortMode(GridSortMode.SingleColumn);
})
.Scrollable(s => s.Height("auto"))
.DataSource(ds => ds
.Ajax()
.Batch(false)
.PageSize(20)
.ServerOperation(true)
.Model(model => model.Id("Id"))
.Read(read => read.Action("kgrdDashboardDetails_read", "Home").Data("includeDetailParameters"))
)
)
These are in the _Layout
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2019.1.115/js/kendo.aspnetmvc.min.js"></script>
These are in the specific page where the report viewer is needed
<script src="@Url.Content("~/ReportViewer/js/telerikReportViewer.kendo-13.0.19.116.min.js")"></script>
<script src="@Url.Content("~/ReportViewer/js/telerikReportViewer-13.0.19.116.min.js")"></script>
@(Html.TelerikReporting().ReportViewer()
.Id("rvResultDistViewer")
.ServiceUrl(Url.Content("~/api/reports"))
.ReportSource(rsrcResultDist)
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.FitPage)
.PersistSession(false)
.PrintMode(PrintMode.AutoSelect)
.SendEmail(new SendEmail { Enabled = false })
.EnableAccessibility(false)
.PageMode(PageMode.SinglePage)
.ClientEvents(e =>
{
{
e.Ready("handleViewerReady_main");
e.PageReady("handlePageReady_main");
e.InteractiveActionExecuting("handleResultClick");
}
})
)
I have a Telerik/Kendo MVC Grid and I have some fields which the users should fill in, and some which are calculated.
I calculate the values for the calculated columns Server Side and I don't feel like replicating complex financial calculations in Javascript as well. :)
So here's the simple requirement:
Grid has 3 columns, A, B & C.
User specifies A and B.
Controller gets the object populated with A and B (Maybe also an old value for C) and calculates C again.
The updated object with the new value for C is saved to the Database AND is passed in the JSon result BACK to the Client.
The Grid should now update and show the new calculated value for C.
Currently C is not updated but if i Refresh the grid manually then the new value for C is shown.
I've checked the Chrome deb
Here is some mockup of what I've got currently. I've tried many different things, but don't seem to be getting anywhere.
I've tried adding the event.RequestEnd from other samples I've found on your forums, but as soon as i add any events, then the inline editing breaks completely.
@(Html.Kendo().Grid((IEnumerable<emscredit.Models.Invoice>)Model.Invoices)
.Name("grid")
.Columns(columns =>
{
columns.Select().HeaderHtmlAttributes(new { style = "width:25px" }).HtmlAttributes(new { style = "width:25px" });
columns.Bound(p => p.A).Format("{0:R#,##0.00}");
columns.Bound(p => p.B).Format("{0:R#,##0.00}");
columns.Bound(p => p.C).Format("{0:R#,##0.00}");
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable(pageable => pageable.ButtonCount(5))
.Sortable(sortable => sortable.AllowUnsort(false))
.Scrollable()
.Filterable()
.Groupable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(false)
//.Events(events =>
//{
// events.Error("error_handler");
// events.RequestEnd("request_end");
//})
.AutoSync(true)
.Model(model => model.Id(i => i.Id))
.Read(read => read.Action("Index", "InvoiceGrid"))
.Update(update => update.Action("UpdateGrid", "InvoiceGrid"))
.Create(create => create.Action("AddToGrid", "InvoiceGrid"))
)
)
Some example from the controller for clarity. Obviously calculation code removed etc.
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult UpdateGrid([DataSourceRequest] DataSourceRequest request, emscredit.Models.Invoice invoice)
{
if (invoice != null && ModelState.IsValid)
{
var entity = db.InvoiceModels.FirstOrDefault(i => i.Id == invoice.Id);
entity.A = invoice.A;
entity.B = invoice.B;
invoice.C = entity.C = invoice.A * invoice.B; // For clarification purposes only
db.SaveChanges();
}
return Json(invoice);
//.ToDataSourceResult was removed as it only caters for a list, not a single object
}
Like I said, i checked the network tab in Chrome and it shows the updated value for C coming back. So Controller seems fine. Just need to configure the grid to update the new calculated value without having to refresh the entire page.
Thanks!
Bruce
I have a grid that has
.Excel(excel => excel
.FileName("Global Agenda Dashboard Grid.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("Export", "Excel"))
.AllPages(true)
I have a Excel controller and in there a method
[HttpPost]
public ActionResult Export(string contentType, string base64, string fileName)
{
var fileContents = Convert.FromBase64String(base64);
return File(fileContents, contentType, fileName);
}
But as far as I can tell this function is not getting called, but the export is happening. Ideas?
I'm experiencing the issue described in this thread:
https://github.com/telerik/kendo-ui-core/issues/3793
In other words, I've downloaded Telerik.UI.for.AspNet.Mvc5 (v2019.1.220) from NuGet and my project won't build unless I open the .csproj file and set MvcBuildViews to false. Obviously, this is not ideal as it means changing that flag every time I want to build. The only other workaround I know of is to remove the offending template files, but this would break some of the controls, as mentioned in the thread.
Do you know of any other workarounds?