Telerik Forums
UI for ASP.NET MVC Forum
7 answers
2.8K+ views
Hi team,

I am new to Kendo UI Grid, for the last two days trying to do custom pagination for kendo grid using Stored Procedure which takes care of pagination with the pageindex and pagesize as sql parameters, for which I dint see any example.

When I exactly followed the steps to do pagination(http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/ajax-binding)  I am getting the following error

System.Linq.IQueryable<object> doesn't contain a definition for ToDataSourceResult and no extension method for ToDataSourceResult accepting a first argument of type System.Linq.IQueryable<object>

I have already included Kendo.MVC.UI namespace in my code.

Please let me know where I am going wrong for ToDataSourceResult.

Regards
VKC


Chris
Top achievements
Rank 1
 answered on 29 Mar 2019
6 answers
731 views
I made a demo project with two entity types: TestModel1 and TestModel2. TestModel1 has a collection property called TestModel2s, which is ICollection<TestModel2>.
Then I use TestModel1 as MVC model type, and I want to bind TestModel2s to a Grid, while editing TestModel1's properties with the grid in the same form. I tried several times to post to the server, the TestModel2s properties was always null.

Is there any simple way to go through this small problem? I think this complex object is not complex at all. Please refer to the home index.cshtml page, that is a simple demo. Attachments are size limited, so the attached demo project hasn't include the kendo's files.
My further requirement is to edit a ICollection<T> property in a column, how can I bind the ICollection<TestModel1> to a Grid and edit ICollection<TestModel2> (field m=>m.TestModel2s) ?

Anxious waiting it.
Boyan Dimitrov
Telerik team
 answered on 28 Mar 2019
9 answers
829 views

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

Tsvetina
Telerik team
 answered on 27 Mar 2019
2 answers
100 views

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"))
                )
        )

Bill
Top achievements
Rank 1
 answered on 27 Mar 2019
1 answer
228 views

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

 

Konstantin Dikov
Telerik team
 answered on 27 Mar 2019
1 answer
988 views
Currently I display a grid that has X columns. I export it to Excel and it also exports X columns. How do I export Y columns and still only display X columns? Or export different columns than displayed? This would be for a "normal" grid and one that is grouped.
Alex Hajigeorgieva
Telerik team
 answered on 26 Mar 2019
1 answer
76 views

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");
                                }
                            })
            )

Angel Petrov
Telerik team
 answered on 25 Mar 2019
7 answers
2.2K+ views
I want to disable all Saturdays, Sundays and holidays. Please help me how to do that.
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 22 Mar 2019
3 answers
117 views

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

Alex Hajigeorgieva
Telerik team
 answered on 22 Mar 2019
1 answer
729 views

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?

Tsvetomir
Telerik team
 answered on 21 Mar 2019
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
Window
ListView
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
ListView (Mobile)
Pager
Accessibility
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
MediaPlayer
TileLayout
DateInput
Drawer
SplitView
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Template
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Rating
ScrollView
ButtonGroup
CheckBoxGroup
Licensing
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?