Telerik Forums
UI for ASP.NET MVC Forum
2 answers
360 views
We are currently evaluating the various different ways of binding our Backend code to the Kendo UI Grid control.

We have a Ajax enabled Controller and View which successfully uses a EditorTemplate to display a dropdown thus :


    @(Html.Kendo().Grid(Model)
                      .Name("EmployeesGrid")
                      .Columns(columns =>
                                   {
                                       columns.Bound(e => e.PersonFirstName).Width(230).Title("First Name");
                                       columns.Bound(e => e.PersonLastName).Width(230).Title("Last Name");
                                       columns.Bound(e => e.DOB).Width(120).Title("D.O.B");
                                       columns.Bound(e => e.Gender).Width(100).Title("Gender").EditorTemplateName("GenderDropDown");
                                       columns.Bound(e => e.SSN).Width(230).Title("SSN");
                                       columns.Command(command =>
                                                           {
                                                               if (ClaimsAuthorize.CheckAccess(Constants.Actions.Delete, Resources.Employee))
                                                               {
                                                                   command.Destroy();
                                                               }
                                                               if (ClaimsAuthorize.CheckAccess(Constants.Actions.Update, Resources.Employee))
                                                               {
                                                                   command.Edit();
                                                                   command.Custom("ViewDetails").Click("EmployeeDetails");
                                                               }
                                                           }).Width(260).Title("Commands");
                                   })
                      .Editable(editable => editable.Mode(GridEditMode.InLine))
                      .DataSource(datasource => datasource
                                                    .Ajax()
                                                    .ServerOperation(false)
                                                    .Model(model => model.Id(e => e.Id))
                                                    .Events(events => events.Error("error_handler"))
                                                    .Create(create => create.Action("CreateEmployee", "EmployeeAjax"))
                                                    .Read(read => read.Action("ReadEmployees", "EmployeeAjax"))
                                                    .Update(update => update.Action("EditEmployee", "EmployeeAjax"))
                                                    .Destroy(delete => delete.Action("DeleteEmployee", "EmployeeAjax"))
                      )
                      .ToolBar(tb =>
                                   {
                                       if (ClaimsAuthorize.CheckAccess(Constants.Actions.Create, Resources.Employee))
                                       {
                                           tb.Create();
                                       }
                                   })
                           .Pageable()
                      .Sortable()
                      .Scrollable()
                      .Filterable()
                      .Resizable(c => c.Columns(true))
                      .Reorderable(c => c.Columns(true))
                      .ColumnMenu()
                      .Groupable())


And the GendorDropDown partial view looks like:


    @(Html.Kendo().DropDownListFor(m => m)
      .Name("Gender")
      .DataTextField("Text")
      .DataValueField("Value")
      .BindTo(new List<SelectListItem>
                  {
                      new SelectListItem {Text = "Male", Value = "M"},
                      new SelectListItem {Text = "Female", Value = "F"}
                  }))


However if I try to setup a Server Bound View using the same template it fails to render the dropdown at all. The column appears but with a value but this disappears completely when attempting to edit the line.


The code for the failing view is below:


    @(Html.Kendo().Grid(Model)
                      .Name("EmployeesGrid")
                      .Columns(columns =>
                                   {
                                       columns.Bound(e => e.PersonFirstName).Width(230).Title("First Name");
                                       columns.Bound(e => e.PersonLastName).Width(230).Title("Last Name");
                                       columns.Bound(e => e.DOB).Width(120).Title("D.O.B");
                                       columns.Bound(e => e.Gender).Width(100).Title("Gender").EditorTemplateName("GenderDropDown");
                                       //columns.ForeignKey(e => e.Gender, new List<SelectListItem>
                                       //                                      {
                                       //                                          new SelectListItem {Text = "Male", Value = "M"},
                                       //                                          new SelectListItem {Text = "Female", Value = "F"}
                                       //                                      }, "Value", "Text").Width(100).Title("Gender");
                                       columns.Bound(e => e.SSN).Width(230).Title("SSN");
                                       columns.Command(command =>
                                                           {
                                                               if (ClaimsAuthorize.CheckAccess(Constants.Actions.Delete, Resources.Employee))
                                                               {
                                                                   command.Destroy();
                                                               }
                                                               if (ClaimsAuthorize.CheckAccess(Constants.Actions.Update, Resources.Employee))
                                                               {
                                                                   command.Edit();
                                                                   command.Custom("ViewDetails").Action("Details", "Employee").Text("Details");
                                                               }
                                                           }).Width(260).Title("Commands");
                                   })
                      .Editable(editable => editable.Mode(GridEditMode.InCell))
                      .DataSource(datasource => datasource
                      .Server()
                      
                              .Model(model => { model.Id(e => e.Id);
                                                  model.Field(e => e.DOB).DefaultValue(null);
                              })
                      .Create(create => create.Action("Create","Employee"))
                      .Read(read => read.Action("Index","Employee"))
                      .Update(update => update.Action("Edit","Employee"))
                      .Destroy(delete => delete.Action("Delete","Employee"))
                      )
                      .ToolBar(tb =>
                                   {
                                       if (ClaimsAuthorize.CheckAccess(Constants.Actions.Create, Resources.Employee))
                                       {
                                           tb.Create();
                                       }
                                   })
                      .Pageable()
                      .Sortable()
                      .Scrollable()
                      .Filterable()
                      .Resizable(c => c.Columns(true))
                      .Reorderable(c => c.Columns(true))
                      .ColumnMenu()
                      .Groupable())


It unclear to me reading the documentation to see if this is even supported or whether the partial view for the template needs to look different. Any help with this would be greatly appreciated and sorry for the masses of cut and paste code.
Atanas Korchev
Telerik team
 answered on 24 Dec 2012
1 answer
154 views
Hello again,
In the local examples for kendo ui with mvc there is no example with popup editing,and online is only in html/jquery.
is there a example you can send me for mvc,because as i saw,in the grid for Editable parameter there is a value for Mode,Popup and i would like to know how can i use it.

Thank you
Dimo
Telerik team
 answered on 21 Dec 2012
2 answers
574 views
Hello,

I was wondering how strict the 30 day trial period is for MVC?  Is it in anyway enforced by the included DLL to prevent use after 30 days?

I only ask, as I set it up in my dev environment earlier this week, got it working in one of my projects, but now I won't have time to work on any of my projects until January.

As I won't be using it over the Christmas period, it seems I won't get to actually trial this product if it prevents execution after 30 days.  (30 days seems a bit odd for a development library to be honest anyway.. couldn't you just limit it to only work on localhost, and not via any other domain / remote client ip?).


Thanks,
Shannon.
Shannon
Top achievements
Rank 1
 answered on 21 Dec 2012
1 answer
291 views
i am new to kendo ui, i have a requirement with grid, i want to display grid like attached image. 
is it possible with kendo grid? if this is possible, please provide some example code.
please see the attachment.
Nikolay Rusev
Telerik team
 answered on 21 Dec 2012
6 answers
823 views
Is it possilbe to embed a List View into a Kendo Grid column via a client template?  
If it's possible how to you bind the List view to the Permmisions list? (Permissions being an IEnumberable<PermissionModel>) 

@(Html.Kendo().Grid<RoleModel>()
    .Name("RoleGrid")
    .Columns(x =>
                 {
                     x.Bound(p => p.Name).Width(150);
                     x.Bound(p => p.Description).Width(350);
                     x.Bound(p => p.Permissions).ClientTemplate("test");                   
                     
                     x.Command(command =>
                                   {
                                       command.Edit();
                                       command.Destroy();
                                   });
                 }))


<script type="text/x-kendo-template" id="test" >
    @(Html.Kendo().ListView<PermissionModel>().Name("listView")
                                                                                     .AutoBind(true)
                                                                                     .ToClientTemplate()
                                                                                     )
</script>
Mike
Top achievements
Rank 1
 answered on 20 Dec 2012
1 answer
1.4K+ views

Hello ,

I have a kendoGrid in form with different clientTemplate like this :

@using (Ajax.BeginForm("edition","activites",null,new { id = id + "formSaisieHeures", width = "100%" }))
    {
 @(Html.Kendo().Grid<Integraal.Models.Activite>()
    .Name(id+"GrilleSaisieHeures")
    .Columns(columns =>
    {
        columns.Bound(p => p.rowId)
            .ClientTemplate("#= rowId #" + "<input type='hidden' name='Activites[#= index(data)#].rowId' value='#= rowId #' />")
            .Hidden();
        columns.Bound(p => p.date)
            .ClientTemplate("#= kendo.toString(date,'d') #" + "<input type='hidden' name='Activites[#= index(data)#].date' value='#= kendo.toString(date,'dd/MM/yyyy') #' />")
            .Width(100);
        columns.Bound(p => p.client.code)
            .ClientTemplate("#= client.code #" + "<input type='hidden' name='Activites[#= index(data)#].client.code' value='#= client.code #' />")
            .Width(100);
        columns.Bound(p => p.client.raisonSociale)
            .ClientTemplate("#= client.raisonSociale #" + "<input type='hidden' name='Activites[#= index(data)#].client.raisonSociale' value='#= client.raisonSociale #' />")
            .Width(150);
        columns.Bound(p => p.affaire.code)
            .ClientTemplate("#= affaire.code #" + "<input type='hidden' name='Activites[#= index(data)#].affaire.code' value='#= affaire.code #' />")
            .Width(100);
        columns.Bound(p => p.affaire.mnemonique)
            .ClientTemplate("#= affaire.mnemonique #" + "<input type='hidden' name='Activites[#= index(data)#].affaire.mnemonique' value='#= affaire.mnemonique #' />")
            .Width(150);
        columns.Bound(p => p.heures)
                //.ClientTemplate(Html.Kendo().NumericTextBox<Decimal>()
                //        .Name("Activites[#=index(data)#].heures")
                //        .HtmlAttributes(new { type = "hidden", value = "#=heures#" })
                //        .Format("{n2}")
                //        .Decimals(2)
                //        .Min(0)
                //        .ToClientTemplate().ToHtmlString()
                // )
                 
            .ClientTemplate("#= heures #" +
                    "<input type='hidden' name='Activites[#= index(data)#].heures' value='#= heures #' data-format='n2' data-decimals='2' data-step='0.01' data-role='numerictextbox' />")                                  
                //.ClientGroupFooterTemplate("Heures : #=sum#")               
                .Width(100);
        columns.Bound(p => p.deplacement)
            .ClientTemplate("#= deplacement #" + "<input type='hidden' name='Activites[#= index(data)#].deplacement' value='#= deplacement #' />")
                .Width(100);
        columns.Bound(p => p.zone)
            .ClientTemplate("#= zone.libelle #" + "<input type='hidden' name='Activites[#= index(data)#].zone.code' value='#= zone.code #' />")
                .Width(150);
        columns.Command(command => command.Destroy()).Width(30);       
    })
        .Events(events => events.DataBound("onDataBoundSaisieHeures"))
        .ToolBar(toolbar =>
        {
            toolbar.Create();
        })
    .Resizable(resize => resize.Columns(true))
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Selectable(selectable => selectable.Mode(GridSelectionMode.Multiple))
    .Sortable()
    .Scrollable()
    .Navigatable() // Permet de changer de cellule en édition par exemple ! ;-)
    .Groupable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Aggregates(aggregates =>
        {
            aggregates.Add(p => p.heures).Sum();
        })
         
        .Batch(true)
        .ServerOperation(false)
        .Model(model =>
            {
                model.Id(p => p.rowId);
                // On indique des valeurs par défaut pour le bind des objets sinon erreur.
                model.Field(p => p.client).DefaultValue(
                     new Integraal.Models.ActiviteClientViewModel
                    {
                        code = "",
                        raisonSociale = ""
                    }
                );
                model.Field(p => p.affaire).DefaultValue(
                     new Integraal.Models.Affaire
                    {
                        code = "",
                        mnemonique = ""
                    }
                );
                model.Field(p => p.zone).DefaultValue(
                        new Integraal.Models.Zone
                        {
                            code = "",
                            libelle = ""
                        }
                );
            })
        .Read(read => read.Action("editing_read", "activites").Data("additionalDataRead"))
    )
)

 

my problems is on the columns "heures", i need to send a Decimal value to the controller.
my models "Activite" have correct data type for the columns "heures"
[DisplayName("Heures")]
[UIHint("Decimal")]
[DisplayFormat(DataFormatString = "{n2}")]
public Decimal heures { get; set; }

my input value is good in the html
(exemple : <input type="hidden" data-role="numerictextbox" data-step="0.01" data-decimals="2" data-format="n2" value="6.66" name="Activites[1].heures">)

"<input type='hidden' name='Activites[#= index(data)#].heures' value='#= heures #' data-format='n2' data-decimals='2' data-step='0.01' data-role='numerictextbox' />"

 


But in my controller the activite.heures is always at 0 -_-'
all others values are set correctly except heures
 

[HttpPost]
public PartialViewResult Edition(Activite activite)
{
List<Activite> edited = new List<Activite>();
List<Activite> deleted = new List<Activite>();
...

someone have any idea ?

 

 

 

Daniel
Telerik team
 answered on 20 Dec 2012
1 answer
197 views
I have a grid set up inside a Kendo Window. If I click on a link, I open the window, and call grid.datasource.refresh from javascript. The first time I do this, it works perfectly. Once I close the window, if I try to reopen it and reload the grid with other data, the grid never refreshes. The weird part is that this only happens with IE 9. Using the latest versions of IE, Chrome and Firefox all work. Any ideas?

Grid MVC Code:
@(Html.Kendo().Grid<Person>()
	    .Name("grid")
	    .Columns(columns =>
	                {
	                    columns.Bound(x => x.FirstName).Title("First Name");
	                    columns.Bound(x => x.LastName).Title("Last Name");
	                    columns.Bound(x => x.EmailAddress).Title("Email Address");
	                    columns.Bound(x => x.PhoneNumber).Title("Phone Number");
	                })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("LoadGrid""Dashboard")
                .Data("my.view.parms"// the name of the JavaScript function which will return the additional data
            )
        )
    )

JS:
var show = function () {
        reloadGrid("#grid");
        showWindow("#window""Lead Report");
    };

var reloadGrid = function(gridElement) {
        var grid = $(gridElement).data("kendoGrid");
        grid.dataSource.read();
    };

var showWindow = function(element, title, width, actions) {
        var window = $(element);
 
        window.show();
 
        if (!window.data("kendoWindow")) {
            window.kendoWindow({
                width: width || "1400px",
                title: title,
                actions: actions || ["Close"],
                modal: true
            });
        }
 
        $(element).data("kendoWindow").center().open();
    };
Petur Subev
Telerik team
 answered on 20 Dec 2012
1 answer
129 views
Hello,

I have a menu that I would like to use content in such as the "Stores" menu option in the example found here.  Basically I want to add HTML markup to a parent menu item.  Is this possible?

Thank you,
David A.
Petur Subev
Telerik team
 answered on 19 Dec 2012
2 answers
367 views
Hi,

I need your help to declare kendogrid which contains a complex field:Specifically ,i have a relation 1-to-1 between table RapportView and table Delegue.I hope to put the "ID"and "Gamme" of table delegue in the same row as rows of RapportView .
My data has type as json like this:
[{ "Cycle":"2008",
"DateDebut":"\/Date(1202684400000+0100)\/",
"DateFin":"\/Date(1203202800000+0100)\/"
,
"Delegue":{"Gamme":"BU 1A","ID":13,"Matricule":"033","Nom":"S","Prenom"
:"Sa","Role":null}
},
{

"Cycle":"2008",
"DateDebut":"
\/Date(1203289200000+0100)\/",
"DateFin":"\/Date(1203807600000+0100)\/",

 "Delegue":{"Gamme":"BU 1A","ID":13,"Matricule":"033","Nom":"S","Prenom":"Sa","Role":null}
}]
i hope that my problem is clear.Thanks for yr help.
nessrine
Top achievements
Rank 1
 answered on 19 Dec 2012
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
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
Security
ColorPicker
DateRangePicker
Wizard
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
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?