Telerik Forums
UI for ASP.NET MVC Forum
6 answers
160 views
Hi,

we're using a Grid with Virtual Scroll Paging enabled and have found that when we scroll down the list and get past the PageSize record (in our case its 300) and its time for it to retrieve the next set of records it calls the controller function defined in .Read() twice... any idea why it calls it twice !? 

Thanks.

Sincerely,

-Igor
Alexander Popov
Telerik team
 answered on 15 May 2014
6 answers
503 views
I have a menu where I wanted to make the text labels hidden and only have the top menu item choices show the image when the screen / client area is a smaller size and found it actually pretty easy to do:

<style type="text/css">
@@media only screen and (max-width: 920px){
    #RootMenu .menuItemText { display:none; visibility: hidden;}                 
 }
</style>

and for the menu:

 @(Html.Kendo().Menu()        
                .Name("RootMenu")
                .HtmlAttributes( new {style="white-space:nowrap;overflow:hidden;max-height:38px;"} )
                .HighlightPath(false)
                .Orientation(MenuOrientation.Horizontal)
                .Items(items => {
                  
                    items.Add().Text("<span class='menuItemText'>Home</span>").Action("Index", "Home").ImageUrl("~/Images/home-white-24.png").Encoded(false);
                 })
        
 )

The key is to wrap the menu item text in span with a classname and making sure .Encoded(false) is set.

From there the media query will do the rest.

Have it working quite nicely at http://www.renepilon.com

Mark
Top achievements
Rank 1
 answered on 15 May 2014
2 answers
203 views
Hi All,

I am trying the Kendo grid. Especially when using the incell mode. It seem like i can't go to the next cell bellow.
If you imagine excel, i want update the sheet in column A. Now i am updating the value of A1, then i want to update cell A2.
In Excel i can just use the down key to move to cell A2.
How can we do it in Kendo Grid?

Please find the code at other thread:
http://www.telerik.com/forums/can%27t-choose-the-first-item-in-dropdown-on-kendo-grid-colum-foreignkey

Thanks in advance.
Csa
Top achievements
Rank 1
 answered on 15 May 2014
1 answer
163 views
I have some questions regarding the MVC Server wrappers.

1. Is there any true benefit for the MVC Server wrappers other than time saved form manually coding the JS? Like are there some special tricks or handlers that are only available via the server wrappers?

2. Is there anyway to specify the dataType for the Wrapper DataSource builder? Example if im using WebApi to serve some data if i use the grid and use the Ajax or WebApi Datasource builder i get nothing but using that same WebApi endpoint if i use the client-side initializing it works. Sample code at the end.

3. What are the pros and cons for the server side functions like Paging, sorting etc..

***************** CODE for # 2 ************************
@model Tsms.Az.Dds.Dto.ViewModels.Classroom.AvailableViewModel
 
@{
    ViewBag.Title = "WebApi";
}
 
<h2>WebApi</h2>
 
<h3>MVC Wrappers</h3>
<div>
    @(Html.Kendo()
        .Grid<Tsms.Az.Dds.Dto.ViewModels.Classroom.AvailableGridItem>()
        .Name("AvailableClassesGrid")
        .Columns(columns =>
        {
            columns.Bound(c => c.ClassDateColumn).Title("Date").Width(150)
                .ClientTemplate(
                    "<span class='ac#= ClassroomType#-#: LanguageType# ;'>#= ClassDateColumn#</span>" +
                    "<br/><br/>" +
                    "# if ( window.location.pathname.indexOf('/Register/Classroom') == 0 ) { #" +
                        "<a data-tsms='acAction' class='button red'><i class='icon-ok'></i> Select</a>" +
                    "# } else { #" +
                        "<a href='Register/Classroom?classID=#=ClassroomID#' data-tsms='acAction' class='button red'>Register</a>" +
                    "# } #"
                );
            columns.Bound(c => c.ClassLocationColumn).Title("Address").Encoded(false).ClientTemplate("<span class='ac#= ClassroomType#-#: LanguageType# ;'>#= ClassLocationColumn#</span>");
            columns.Bound(c => c.ClassDirectionsColumn).Title("Directions").Width(250).Encoded(false).ClientTemplate("<span class='ac#= ClassroomType#-#: LanguageType# ;'>#= ClassDirectionsColumn#</span>");
            columns.Bound(c => c.DisplayCity).Visible(false);
            columns.Bound(c => c.ClassTimeColumn).Visible(false);
        })
        .Pageable(p => p.Enabled(Model.GridSettings.PageableSettings.Enabled).PageSizes(Model.GridSettings.PageableSettings.Enabled))
        .Sortable(s => s.Enabled(Model.GridSettings.SortableSettings.Enabled))
        .Scrollable(s => s.Enabled(Model.GridSettings.ScrollableSettings.Enabled))
        .Selectable(s => s.Enabled(Model.GridSettings.SelectableSettings.Enabled))
        .Filterable(f => f.Enabled(Model.GridSettings.FilterableSettings.Enabled))
        .DataSource(source => source
            .Ajax()
            .ServerOperation(false)
            .Read(read => read.Url("/api/classroom/get-available-grid-list-test").Type(HttpVerbs.Get))
        )
        .Deferred()
    )
</div>
 
<hr />
<h3>Client Side</h3>
<div id="grid"></div>
 
@section scripts
{
<script>
                $(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "json",
                            transport: {
                                read: "/api/classroom/get-available-grid-list-test"
                            },
                            pageSize: 5,
                            serverPaging: false,
                            serverFiltering: false,
                            serverSorting: false
                        },
                        height: 430,
                        filterable: true,
                        sortable: true,
                        pageable: true,
                        columns: [{
                                field: "ClassDateColumn",
                                filterable: false
                            },
                            "ClassLocationColumn"
                        ]
                    });
                });
</script>
}
Vladimir Iliev
Telerik team
 answered on 14 May 2014
1 answer
1.8K+ views
I want to filter a grid via JavaScript, but cant seem to work out how to pass data,
I have tried like this, Can this be done, thanks
​
var grid = $("#StudentInvoices").data("kendoGrid");
grid.dataSource.read({ "page": 1, "pageSize": 10, "filter": "Paid~eq~false" })
Dimiter Madjarov
Telerik team
 answered on 14 May 2014
3 answers
2.0K+ views
I'm attempting to add a handler for errors to an MVC grid wrapper.  My grid gets its data and does editing via AJAX.  That is working properly.  I'm now trying to add support for authorization/roles so I want to be able to show the user a message when they don't have access and, for example, click on the Edit button.

All the samples I've seen use events.error.  So I created a grid as below with a javascript function as below.  However, when trying to show the view in the browser I get a compilation error in the browser "'Kendo.Mvc.UI.Fluent.GridEventBuilder' does not contain a definition for 'Error' and no extension method 'Error' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.GridEventBuilder' could be found (are you missing a using directive or an assembly reference?)"

I'm sure I must be missing something simple.  Can anyone offer assistance in where I've gone off the tracks?  At least as helpful, can you point me to the correct spot in the documentation to find this information?

@(Html.Kendo().Grid<KendoMVC4.Models.Power>()
      .Name("grid")
      .DataSource(dataSource => dataSource // Configure the grid data source
                    .Ajax() // Specify that ajax binding is used
                    .Read(read => read.Action("ExecutedPowers_Index", "Powers")) // Set the action method which will return the data in JSON format
                    .PageSize(10)
                    .Model(model => model.Id(p => p.ID))
                    .Create(update => update.Action("Power_Create", "Powers"))
                    .Update(update => update.Action("Power_Update", "Powers"))
                    .Destroy(update => update.Action("Delete", "Powers"))
                 )
                .Columns(columns =>
                {
                    columns.Bound(p => p.PowerNumber);
                    columns.Bound(p => p.Status);
                    columns.Command(command => { command.Edit(); command.Destroy();  }).Width(200);
                    columns.Command(command => { command.Custom("Forfeit").Click("showForfeit"); });

                })
                .Pageable()
                .Sortable()
                .ToolBar(toolbar => toolbar.Create())
                                .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("PowerEditor")
                                    .Enabled(User.IsInRole("PowerEditor"))
                                    .Window(w => w.Title("Edit Power Details"))
                                    .Window(w => w.Width(560))
                                    .Window(w => w.Height(750))
                                 )
                .ClientDetailTemplateId("client-powerDetails")
                .Events(events => events.Error(@<text>function(e) { $.proxy(error, $("#Grid").data("kendoGrid"))(e); }</text>))
    
                )

<script type="text/javascript">
function grid_errorHandler(e) {
        if (e.errors) {
            var message = "Errors:\n\n";
            $.each(e.errors, function (key, value) {
                if ('errors' in value) {
                    $.each(value.errors, function () {
                        message += this + "\n\n";
                    });
                }
            });
            alert(message);
        }
        else if (e.xhr.status == 401) {
            //show message
            var grid = $("#grid").data("kendoGrid");
            grid.table.on("click", "tbody > tr", function (e) {
                e.stopPropagation();
            });
            grid.element.find("> .k-grid-toolbar").hide();
        }
    }
</script>
Daniel
Telerik team
 answered on 14 May 2014
8 answers
448 views

I have a problem on date display in grid. I already read some  issue here in this forums but still there's no solution.

My problem is the "p.CreatedDate" field which is not displaying properly. See attached image file

I hope you could help me on this.

Thank you and God bless...

Here's my code below:

Html.Kendo().Grid(Of SPIMS.ViewModel.EventViewModel.Index)() _
                .Name("grid") _
                .Sortable _
                .Columns(Sub(c)
                                 c.Bound(Function(p) p.ID).HeaderHtmlAttributes(New With {.style = "text-align: center; font-weight: bold"}).Width(10)
                                 c.Bound(Function(p) p.CreatedDate).Format("{0:dd/MM/yyyy}").Width(20).Title("Date").HeaderHtmlAttributes(New With {.style = "text-align: center; font-weight: bold"})
                                 c.Bound(Function(p) p.Source).HeaderHtmlAttributes(New With {.style = "text-align: center; font-weight: bold"}).Width(20)
                                 c.Bound(Function(p) p.Message).HeaderHtmlAttributes(New With {.style = "text-align: center; font-weight: bold"}).Width(50).Title("Description")
                                 c.Command(Sub(commands)
                                                   commands.Custom("View").Click("showDetails")
                                           End Sub).Title(" ").Width(10)
                         End Sub) _
                .Scrollable() _
                .Filterable() _
                .Pageable(Sub(pager)
                                  pager.Input(True)
                                  pager.Numeric(True)
                                  pager.Input(True)
                                  pager.PreviousNext(True)
                                  pager.Refresh(True)
                                  pager.PageSizes(True)
                                  pager.ButtonCount(10)
                          End Sub) _
                .HtmlAttributes(New With {.style = "height:450px;width:900px;"}) _
                .DataSource(Sub(d)
                                    d.Ajax() _
                                    .PageSize(10) _
                                    .Model(Sub(model) model.Id(Function(p) p.ID)) _
                                    .ServerOperation(True) _
                                    .Read(Function(read) read.Action("Model_Read", "Event"))
                            End Sub).Render()
Silver Lightning
Top achievements
Rank 1
 answered on 14 May 2014
2 answers
244 views
Hello,

I am a first time user of Kendo UI for ASP.NET MVC. The version I am using is Q1 2014 (2014.1.318). In Kendo Grid while doing custom server binding, if I keep on clicking a column header for sorting, on every third click, the grid misses to send the sort descriptor to the server and the sort order falls back to default . The same happens when I tried the custom server binding from the demo which comes with the product installation. I sorted the column 'Ship City' and on every third click I can see that the 'Grid-sort:' parameter value is empty (I used Chrome developer tool to check this). On the next two clicks, I can see it as 'ShipCity-asc' and 'ShipCity-desc'. I have attached a screen shot which shows the issue in the demo. Can anyone kindly suggest why this might be happening?

Thanks

Shameer
Shameer
Top achievements
Rank 1
 answered on 14 May 2014
3 answers
682 views
Hi,

      I have a grid and i need to set hyperlink for three columns and also I have these column font color change depend on the column value... How do i do that..

here is my Index.cshtml

columns: [
           { field: "BatchNo", width: "150px" },
           { field: "BatchDate",
             width: "250px",
            format: "{0:dd-MMM-yyyy hh:mm:ss tt}",
      parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"] },
           { field: "FileType", width: "250px" },
           { field: "BatchFileName", width: "600px" },
           { field: "BatchRecords", title: "StageCount", width: "150px", template: "\u003cb\u003e\u003ca href=\u0027/#=FileType#/Index?Batchno=#=BatchNo#\u0027\u003e#=BatchRecords#\u003c/a\u003e\u003c/b\u003e" },
           { field: "LoadCount", width: "150px", template: '#=SetLoadColor(BatchRecords,LoadCount,ReportCount)#'  },
           { field: "ReportCount", width: "150px", template: '#=SetReportColor(BatchRecords,LoadCount,ReportCount)#' },
           { field: "Status",
             width: "150px",
             template: "#=Status#",
             editor: statusDropDownEditor
           },
           { field: "EntityCode", width:"150px" },
           { field: "EntityName", width:"150px" },
           { field: "CreatedBy", width:"200px" },
           { field: "CreatedDate",
             width:"250px",
              format: "{0:dd-MMM-yyyy hh:mm:ss tt}",
      parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"] },
           { field: "ModifiedBy", width:"350px" },
           { field: "ModifiedDate",
             width:"250px",
              format: "{0:dd-MMM-yyyy hh:mm:ss tt}",
      parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"] },
           { command: ["edit"], title:" ", width:"200px"}],
           editable: "inline",
       pageable: true,
       sortable: true,
       filterable: true,
       columnMenu: true,
       resizable: true,

My Functions to change the column color..

function SetLoadColor(BatchRecords,LoadCount,ReportCount)
{
    if(BatchRecords===LoadCount||LoadCount===0 )
    return LoadCount;
    else
    return "<font color=\"red\">"+LoadCount+"</font>";
}
 
function SetReportColor(BatchRecords,LoadCount,ReportCount)
{
    if(BatchRecords===ReportCount&&LoadCount===ReportCount||ReportCount===0 )
    return ReportCount;
    else
    return "<font color=\"red\">"+ReportCount+"</font>";
}

I need to set hyperlink like this "href=/#=FileType#/Index?Batchno=#=BatchNo" on all three columns...along with color change rule..

Dimiter Madjarov
Telerik team
 answered on 13 May 2014
1 answer
421 views
Hi

I'm sure this is relatively straightforward but all my columns are showing correctly except for a time column which is showing as [object][object].

property is type System.TimeSpan

Any ideas?

Thanks
Ant
Top achievements
Rank 1
 answered on 13 May 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?