Telerik Forums
UI for ASP.NET MVC Forum
1 answer
167 views

I have a simple Kendo UI grid setup for serverside processing which displays some employee information.  The grid displays just fine when i first load the view but as soon as you click on a column to sort it refreshes and just gives me an empty grid.  The Action is firing each time a column header is click and is returning the correct amount of records to the view.  See my code below:

View:

@ModelType List(Of ConnectEntities.Employee)
 
@Code
    ViewData("Title") = "CompanyDirectory"
    Layout = "~/Views/Shared/_HomeLayout.vbhtml"
 
End Code
 
 
    <div class="row">
 
        <div class="col-md-12">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Company Directory</h4>
 
                </div>
                <div class="panel-body">
                    @Code
                        Html.Kendo.Grid(Of ConnectEntities.Employee)() _
                                                    .Name("employeeDirectory") _
                                                    .BindTo(DirectCast(ViewData("employees"), IEnumerable(Of ConnectEntities.Employee))) _
                                    .Columns(Sub(c)
                                                 c.Bound(Function(p) p.FirstName_AD).Sortable(True)
                                                 c.Bound(Function(p) p.LastName_AD)
                                                 c.Bound(Function(p) p.JobTitle_AD)
                                                 c.Bound(Function(p) p.PhoneNumber_AD)
 
                                             End Sub) _
                                                                                     .DataSource(Sub(d)
                                                                                                     d.Server() _
                                                                                                     .Read(Function(read) read.Action("Person_Read", "Home"))
 
                                                                                                 End Sub) _
                                                                                     .Sortable() _
                                                                                     .Filterable() _
                        .Render()
 
 
 
                    End Code
 
 
                </div>
            </div>
        </div>
    </div>

 

Controller Code:

Function CompanyDirectory() As ActionResult
 
    Dim employees As List(Of ConnectEntities.Employee)
 
    Using connectDB As New ConnectEntities.ConnectEntities
        employees = connectDB.Employees.ToList
    End Using
 
    ViewData("employees") = employees
 
    Return View()
 
 
End Function

 

Public Function Person_Read() As ActionResult
 
 
    Dim employees As List(Of ConnectEntities.Employee)
 
    Using connectDB As New ConnectEntities.ConnectEntities
        employees = connectDB.Employees.ToList
    End Using
 
    Return View("CompanyDirectory", employees)
 
 
End Function

 

 

Pavlina
Telerik team
 answered on 21 Jun 2016
4 answers
176 views

Hi,

 

The grid column headers split the view model property names when there is an uppercase character in the viemodel property name. That is good. But when I have an non-English character in the name the column header will also be split. Is this the intended behaviour? I know I can workaround the issue by using DisplayName in the model or .Title() in the grid, but that is a lot of unnecessary work.

ViewModel:

    public class AvslagnaIndexViewModel
    {
        public Guid Id { get; set; }
        public string DiarieNummerSSM { get; set; }
        public DateTime AnsökningsDatum { get; set; }
        public string Handläggare { get; set; }
        public string ExportörNamn { get; set; }
        public string SlutanvändareNamn { get; set; }
        public string BestämmelseLandNamn { get; set; }
        public string Status { get; set; }
    }

Grid columns:
        .Columns(columns =>
        {
            columns.Bound(p => p.Id).Hidden().Title("Id");
            columns.Bound(p => p.DiarieNummerSSM).ClientTemplate(
                Html.ActionLink("#=DiarieNummerSSM#", "Details", "Avslagna", new { id = "#=Id#" }, new { title = "Visa ärendedetaljer", @class = "k-link k-grid-edit-row" }).ToHtmlString()).Width(120);
            columns.Bound(p => p.AnsökningsDatum).Format("{0:yyyy-MM-dd}");
            columns.Bound(p => p.Handläggare);
            columns.Bound(p => p.ExportörNamn);
            columns.Bound(p => p.SlutanvändareNamn);
            columns.Bound(p => p.BestämmelseLandNamn);
            columns.Bound(p => p.Status);
        })

See the attached image for the result. All words containing non-English caracters are split in more places than they should be. As you can see "BestämmelseLandNamn" is shown as "Bestä mmelse Land Namn"

Best regards,

Henrik

Henrik
Top achievements
Rank 1
 answered on 21 Jun 2016
2 answers
217 views

I am trying to open a kendo window based on input from a form. I am getting this error:

JavaScript runtime error: Object doesn't support property or method 'open'

The error occurs when win.open(); is called in the JavaScript in the view as listed below. Any help would be great.

Here is my controller:

using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using KendoGridAjaxBinding.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace KendoGridAjaxBinding.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            TheModel m = new TheModel();
 
            return View(m);
        }
 
        public ActionResult Search( TheModel m)
        {
            if (m.Name != string.Empty)
            {
                ViewData["OpenGrid"] = "OpenGrid";
            }
            return View("Index", m);
        }
 
    }
}

Here is my view:

@using System
@using System.Web
@using System.Web.Mvc
@using System.Web.Razor
@using Kendo.Mvc.UI
@using KendoGridAjaxBinding.Models
 
@model TheModel
 
@using (Html.BeginForm("Search", "Home", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    <label for="textinput">Name</label>@Html.TextBoxFor(model => model.Name, new { @class = "input-xs form-control", placeholder = "Name", type = "text" })<br />
    <label for="textinput">Address</label>@Html.TextBoxFor(model => model.Address, new { @class = "input-xs form-control", placeholder = "Address", type = "text" })<br />
    <label for="textinput">City</label>@Html.TextBoxFor(model => model.City, new { @class = "input-xs form-control", placeholder = "City", type = "text" })<br />
    <label for="textinput">State</label>@Html.TextBoxFor(model => model.State, new { @class = "input-xs form-control", placeholder = "State", type = "text" })<br />
    <button id="Search" class="btn btn-primary">Search</button>
}
 
 
 
@(Html.Kendo().Window()
    .Name("window")
    .Width(630)
    .Height(315)
    .Draggable()
    .Resizable()
    .Title("Test Test Test")
    .Actions(actions => actions.Pin().Refresh().Maximize().Close())
    .Visible(false)
)
 
<script type="text/javascript">
    var messageX = '@ViewData["OpenGrid"]';
    if (messageX = "OpenGrid")
    {
        $("#window").kendoWindow();
        var win = $("#window").data("kendoWindow");
 
        var win = $("#window")
        if (win != null)
        {
            win.open();
        }
    }
 
</script>

The Model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace KendoGridAjaxBinding.Models
{
    public class TheModel
    {
        public string Name { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string State { get; set; }
    }
}

Thanks in advance,

rstinson

Randy
Top achievements
Rank 1
 answered on 21 Jun 2016
33 answers
833 views

When do you have a working release?

The nuget package 2016.2.607 does not install.

When do we have a version for payed customer without demo message.

When will the documentation for RC2 be updated?

I know it is a RC but as you advertise and blog about it as if it works I am a little suprised that the quality is so bad.

Jan Olsmar
Top achievements
Rank 1
 answered on 21 Jun 2016
2 answers
170 views

I have a grid bound to a ViewModel, and the 3rd column is bound to an empty property.  This data did not come from a database,so there is no foreign key relationship, in fact there's no database involved at all.  In the 3rd column I would like a drop down.  This would be the same dropdown in each row of the grid. That dropdown should contain a list of properties (List<string>).  When a value is selected,that specific item should be removed from the dropdown list on subsequent rows.

So how can I go about building such a beast?  It's easy enough to do in a WebForm, but alas using MVC and these Kendo components has left a real bad taste in my mouth.  It seems as if everything has to be gotten via an AJAX call, or must call into some action, or must be bound somewhere along the line; and nothing seems to work out of the box.

I'm using this to map a CSV file to an object.  So using the file uploader action, I parse the column headers out of the CSV file, and create a List<CVSColumn> that is actually a property of my CSVColumnsViewModel:

namespace FileUploader_Mapper.Models
{
    public class CSVColumn
    {
        public int ColumnNumber { get; set; }
        public string ColumnName { get; set; }
        public string MappedTo { get; set; }
    }
 
    public class CSVColumnsViewModel
    {
        public string CSVFile { get; set; }
        public List<CSVColumn> Columns = new List<CSVColumn>();
        public List<string> Properties { get; set; }
 
        public CSVColumnsViewModel()
        {
            Properties = new List<string>
            {
                "FirstName",
                "LastName",
                "SSN",
                "Address1",
                "Address2",
                "City",
                "State",
                "Zip"
            };
        }
    }
}

 

In the first column of the grid is the ColumnNumber property, the second column is the ColumnName property, and the 3rd column is empty, but is mapped to the MappedTo property.  What I want to do is show the list of Properties in a dropdown in the third column so the user can choose which property the current column would map to.  Then in the next row, it would only show available properties for the additional columns to map to.

I hope this is making sense...

Here's what I have in my cshtml file

@using FileUploader_Mapper.Models
@model CSVColumnsViewModel
 
@{
    ViewBag.Title = "Result";
}
 
<style>
    .k-grid td {
        line-height: 2em;
        padding: 0 0 0 1em;
    }
</style>
 
<h2>Result</h2>
 
<p></p>
 
@(Html.Label("lblMisc", "Columns from CSV File: " + Model.CSVFile))<br/>
 
@(Html.Kendo().Grid(Model.Columns)
    .Name("csvGrid")
    .HtmlAttributes(new { style = "width: 650px" })
    .Columns(col =>
    {
        col.Bound(c => c.ColumnNumber).Width(125).Title("Column Number");
        col.Bound(c => c.ColumnName).Title("Column Name");
        col.Bound(c => c.MappedTo).Title("Mapped To");
    })
    .DataSource(ds => ds
        .Ajax()
        .PageSize(20)
        .ServerOperation(false)
        .Model(m =>
        {
            m.Id(c => c.ColumnNumber);
            m.Field(c => c.ColumnName).Editable(false);
            m.Field(c => c.MappedTo).DefaultValue(Model.Properties);
 
        })
    )
    .Pageable()
)

I really don't know how to proceed and could use some guidance.

Maria Ilieva
Telerik team
 answered on 21 Jun 2016
1 answer
336 views

Hello,

 

I'm trying to implement a kendo grid with server side sorting and filtering. I want to be able to sort using the DataSourceRequest.Sort object by more than just the member type and sort direction.

 

I essentially want the equivalent of the following IEnumerable OrderBy Method

 

queryList.OrderBy(x => x.SomeMember == SomeConstantValue)

 

Is there a way to do this by using the SortDescriptor Object?

 

Any help would be appreciated

Danail Vasilev
Telerik team
 answered on 21 Jun 2016
3 answers
162 views

When I add an MVC Spreadsheet using this very simple code (in a View page of an MVC app)

@{
    ViewBag.Title = "Index";
}
 
<h2>Index</h2>
 
@{
    var path = Server.MapPath("~/Content/CSVFiles/SUNRISE06142016.csv");
    var workbook = Telerik.Web.Spreadsheet.Workbook.Load(path);
}
 
<div style="background-color: coral; width: 500px; height: 500px; border-style: double">
    @(Html.Kendo().Spreadsheet()
        .Name("spreadsheet")
        .BindTo(workbook))
</div>

The result page is not a spreadsheet, to be sure...  I've attached a screen shot of the page without the spread sheet, and then with the spreadsheet.  What gives here?

Basically what I'm wanting to do is to upload a CSV file, of any format and load it into a spreadsheet component. Ultimately this will be for users to map their CSV uploads to an object for parsing.  Each and every CSV file will most likely be different.

 

Nencho
Telerik team
 answered on 20 Jun 2016
2 answers
352 views

Is it possible to add a bootstrap badge to a tab title?

 

I want to highlight the number of records in a tab panels, which is not initially selected.  Ideally, it would be something like:-

<span class='badge'>10</span>

Where the number would come from a variable (initially from the view bag).

 

Is this possible at all?

AP
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 20 Jun 2016
2 answers
735 views

I've got a sub-grid, which needs to allow records to be inserted, dependant on a value in the parent record.

I've got an onBound handler, which gets passed the subGrid name, but what do I need to do to hide the create button in the toolbar?

The toolbar is defined here:-

@(Html.Kendo().Grid<SystemsHelpDesk.Models.View_Support_Action>()
         .Name("ActionGrid_#=LogID#")
           .Events(e => e.Edit("onEdit"))
         .Columns(columns =>
         {
             columns.Bound(o => o.ActionID).Title("ID");
             columns.Bound(o => o.ActionDate).Title("Date").Format("{0:g}");
             columns.Bound(o => o.CategoryDescription).Title("Category");
             columns.Bound(o => o.ActionDesc).Title("Details");
             columns.Bound(o => o.UserName).Title("User");
 
         })
    .ToolBar(commands => commands.Create().Text("Add Action"))
 
 
 
  .Events(e => e.DataBound(@<text> function(e){onSubBound(e,"ActionGrid_#=LogID#",#=Resolved#)}</text>))
  .Editable(editable => editable
       .Mode(GridEditMode.PopUp))
 
         .DataSource(dataSource => dataSource
 
             .Ajax()
              .Events(e => e.Error(@<text> function(e){subError(e,"ActionGrid_#=LogID#")} </text>).Sync("ActionSync"))
              .Model(m => m.Id(p => p.ActionID))
             .PageSize(10)
                             .Read(read => read.Action("RD_Actions", "Home", new { LogID = "#= LogID #" }))
                               .Create(create => create.Action("InsertAction", "Home", new { LID = "#= LogID #" }))
                   .Update(update => update.Action("UpdateAction", "Home"))
                       .Destroy(delete => delete.Action("DeleteAction", "Home"))
             )
             .Pageable(p => p.Refresh(true))
 
             .ToClientTemplate()
 
   )

I can pass the Grid name and the value of the Boolean field that determines if records should be able to be added, but I'm at a loss at how to hide the button. I have tried:-

function onSubBound(e,gridName,Flag)
            {
               // alert(gridName);
                //alert(Flag);
 
                var grid = $(document.getElementById(gridName)).data("kendoGrid");
 
                $(grid).find("k-grid-toolbar").hide();
 
 
            }

But this doesn't work.

How can I hide the button when I need to?

Thanks

AP
Top achievements
Rank 1
Iron
Iron
Veteran
 answered on 20 Jun 2016
3 answers
151 views

Hello,

I use a PopupEdit Template with cascading DropDownLists and in th second DropDownList a serverfilter (see code)

the problem is, that the template is loaded on grid load and the second DropDownList does'nt work because the value of the
field $("#Fachgruppe_Version_ID").val() in the template is not set at this time...

  • how to solve this problem?
  • I know that there is a onEdit event from the grid but how to call scripts in the template?
  • what's the best way to use Javascript/JQuery in the template (View Components, partial views)?

robert

@(Html.Kendo().DropDownListFor(model => model.Fachgruppe_ID)
                                 .DataTextField("Fachgruppe")
                                 .DataValueField("Fachgruppe_ID")
                                 .BindTo((IEnumerable) ViewData["Fachgruppe"])
                                 .HtmlAttributes(new {style = "width:500px"})
                                 .CascadeFrom("Sparte_ID")
                                 )
 
                           @(Html.Kendo().DropDownList()
                                 .Name("FG")
                                 .HtmlAttributes(new {style = "width:100%"})
                                 .OptionLabel("Select product...")
                                 .DataTextField("Fachgruppe")
                                 .DataValueField("Fachgruppe_ID")
                                 .DataSource(source =>
                                 {
                                     source.Read(read =>
                                     {
                                         read.Action("FachgruppeVersion_Read", "Home")
                                             .Data("filterFachgruppe");
                                     })
                                         .ServerFiltering(true);
                                 })
                                 .Enable(true)
                                 .AutoBind(false)
                                 .CascadeFrom("Sparte_ID")
                                 )
 
                           <script>
                               function filterFachgruppe() {
                                   return {                            
                                       version_id: $("#Fachgruppe_Version_ID").val()
                                   };
                               }
                           </script>

Danail Vasilev
Telerik team
 answered on 20 Jun 2016
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
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
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
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
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?