Telerik Forums
UI for ASP.NET MVC Forum
1 answer
94 views
Hi,

In the following code snippet you see that we are using the MVC Wrapper of kendo ui grid with odata mechanism that gets its data from a controller in server side.
We want to use custom command buttons but we are getting an exception that says that we cannot use custom commands if we are not using server binding. But when we are using odata mechanism with data binding at controller stage, why this is not a server binding ?

Please help.

Thanks.

<div>
    @(Html.Kendo().Grid<Item>()
          .Name("grid")
          .Columns(columns =>
          {
              columns.Bound(c => c.ItemCode);
              columns.Bound(c => c.ItemName);
              columns.Command(command => command.Custom("Details").Text("Details").Action("OpenDetailsForm", "Home")).Width(100);
          })
          .HtmlAttributes(new { style = "height: 380px;" })
          .Scrollable()
          .Selectable(o => o.Mode(GridSelectionMode.Multiple).Type(GridSelectionType.Row))
          .Sortable()
          .Resizable(o => o.Columns(true))
          .Reorderable(o => o.Columns(true))
          .Filterable()
          .Pageable(pageable => pageable
          .Refresh(true)
          .PageSizes(true)
          .ButtonCount(3))
          .DataSource(dataSource => dataSource
          .Custom()
          .ServerSorting(true)
          .ServerFiltering(true)
          .ServerPaging(true)
          .ServerGrouping(true)
          .ServerAggregates(true)
          .Schema(s => s.Total("Total").Data("Data"))
          .Type("odata")
          .PageSize(10)
          .Transport(r => r.Read(c => c.Cache(true)).Read(a => a.Action("GetGridDataSource", "Home", new { entityName = typeof(Item).FullName }).DataType("json")))))
</div>







Alexander Popov
Telerik team
 answered on 02 Mar 2015
9 answers
393 views
I've just finished implementing the Export to Excel functionality from v2014.3.1411 in apps for two different clients. I held off until now because the first version of the functionality, while great, was unusable to me because if the grid had more than one page of data, the export only exported the current page. The latest version with AllPages functionality fully implemented is perfect. It completely meets my clients' needs for ad hoc reporting. Thank you so much and my compliments to the developers involved.
Jolene
Top achievements
Rank 1
 answered on 27 Feb 2015
5 answers
1.5K+ views
Hello,
How can I force the grid to refresh after saving an edit using your pop-up editor? 

After a user saves a new or edited record, its data is encrypted and passed to the database.  When we return to the grid, the new records data is displayed in its encrypted form, but the other records display properly.  After I hit the refresh button on the grid, everything displays properly.  This is the issue that I am trying to correct.

I would appreciate your help and suggestions,
Mike
Kelso
Top achievements
Rank 1
 answered on 27 Feb 2015
1 answer
177 views
In Razor view i have Three divs out of which Two divs are hidden,in hidden div i have declare one div for Grid and i am generating that Grid using html,When i am showing that hidden div then Grid in that div is coming at the left top corner with small size.
When i am clicking on it, it's showing that Grid properly.
I am Showing and Hiding these div using "js" file.

(When i am removing hidden property from that div and loading that div it's not giving me any Problem)i.e
Working Fine Without Hidden:
<div id="xyz" >
<div id="Grid_ID"/>
</div>

Issue  With Hidden Property:
<div id="xyz" hidden="hidden">
<div id="Grid_ID"/>
</div>

I have attached the Snap shot,Kindly Find those.
Dimo
Telerik team
 answered on 27 Feb 2015
1 answer
126 views
I have created a grid which is bound to a list of workgroups. Each workgroup has a list of Agents which I want to show as detail.

The only way I got this working was by doing a  client detail template and creating a new grid. This means doing another read of data which i did not really want to do. 

Can someone advise a better way to do this. Also suggest a good way to style my details as I don't want them shown as a standard grid but actually a list. 
  
Current code:

   <div id="clientsDb">
    <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.WorkgroupViewData>()
        .Name("grid")
         .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Workgroups_Read", "Home", new { name = ViewData["LoggedInUser"] }))
            )
        .Columns(columns =>
        {
            columns.Bound(c => c.WorkgroupName).Width(140);
            columns.Bound(c => c.TotalAgents).Width(75);
            columns.Bound(c => c.AgentsLoggedOn).Width(75);

        })       
        .HtmlAttributes(new { style = "height: 380px;" })
        .Scrollable()
        .Groupable()
        .Sortable()        
        .ClientDetailTemplateId("client-template")
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))     
     %>
 </div>

<script id=" Code:client-template" type="text/x-kendo-template">     
  <%: Html.Kendo().Grid<ASML_Scheduler.ScheduleService.AgentViewData>()
      .Name("grid_#=WorkgroupName#") 
        .DataSource(dataSource =>  
          dataSource.Ajax().Read(read => read.Action("Agents_Read", "Home", new {workgroupname= "#=WorkgroupName#", name = ViewData["LoggedInUser"] }))
      )      
      .Columns(columns =>
      {
          columns.Bound(product => product.AgentName);
          columns.Bound(product => product.IsLoggedOn);
      })       
      .ToClientTemplate()
    %>    
</script>
Alexander Popov
Telerik team
 answered on 27 Feb 2015
1 answer
340 views
Hi There,

I would like to do dynamic columns using list item from MyModel, can i change the column "title" base on MyModel?

MyModel
{
     List<Item> Items;
}


Please refer to code below : 

@(Html.Kendo().Grid<MyModel>()
    .Name("gridStudentList")
    .Columns(columns =>
    {


        for (int i = 0; i < 3; i++)
        {

            columns.Bound(c => c.Items[i].Product).Title("Can i use Mymodel property here?").Filterable(false); 
            columns.Bound(c => c.Items[i].ProductPrice).Filterable(false); 
        }

    })
Thanks for your time. Regards,






Dimo
Telerik team
 answered on 27 Feb 2015
4 answers
287 views
Hello,

I'm using the GridFilterMode.Row but it doesn't work. My Grid is define in two parts :
- on the server :
    public static class GridPluginServeurTypeA
    {
        public static GridBuilder<T> Grid<T>(HtmlHelper htmlHelper) where T : class
        {
            WidgetFactory wf = new WidgetFactory(htmlHelper);
            GridBuilder<T> gb = wf.Grid<T>();
            gb.Name("Grid");
            gb.Pageable(pager => pager.PageSizes(new[] { 5, 10, 20, 50, 75, 100 }).ButtonCount(3).Refresh(true));

            gb.Sortable(s => s.SortMode(GridSortMode.MultipleColumn));
            gb.Navigatable();
            gb.Pageable();
            gb.Groupable();
            gb.Resizable(resiz => resiz.Columns(true));
            gb.Reorderable(reoder => reoder.Columns(true));
            gb.DataSource(dataSource => dataSource.Ajax()
                .PageSize(10)
                .Batch(false)
                .ServerOperation(true)
            );
            gb.Events(e => e.DataBound("onDataBound"));

            return gb;
        }
    }

- on the client :
 Gtool.Utilities.Telerik.Grid.GridPluginServeurTypeA.Grid<Keorisk.Domain.DtoTUtilisateur>(Html)
            .Columns(columns =>
            {
                columns.Bound(p => p.Id).Title(TexteAffiche.Instance.Texte["LstUtilisateurColId"]).ClientTemplate("#= ColonneId(data) #").Locked(true);
                columns.Bound(p => p.Nom).Title(TexteAffiche.Instance.Texte["LstUtilisateurColNom"]).Locked(true).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.Bound(p => p.Prenom).Title(TexteAffiche.Instance.Texte["LstUtilisateurColPrenom"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.ForeignKey(p => p.RoleId, (System.Collections.IEnumerable)ViewData["roles"], "Id", "Libelle").Title(TexteAffiche.Instance.Texte["LstUtilisateurColRole"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.ForeignKey(p => p.StatutId, (System.Collections.IEnumerable)ViewData["statuts"], "Id", "Libelle").Title(TexteAffiche.Instance.Texte["LstUtilisateurColStatut"]).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
                columns.Bound(p => p.Login).Title(TexteAffiche.Instance.Texte["LstUtilisateurColLogin"]);
                columns.Command(com => { com.Edit().Text("Edit"); com.Destroy().Text("Cancel "); });
            })
            .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Utilisateur"))
            .Filterable(ftb => ftb.Mode(GridFilterMode.Row).Enabled(true))
            .DataSource(dataSource => dataSource.Ajax()
                .Model(model => model.Id(user => user.Id))
                .Model(model => model.Field(user => user.Id).Editable(false))
                .Model(model => model.Field(user => user.RoleId).Editable(false))
                .Model(model => model.Field(user => user.StatutId).Editable(false))
                .Read(read => read.Action("GetAllUtilisateursGrid", "Admin"))
                .Update(update => update.Action("UpdateUtilisateurGrid", "Admin"))
                .Destroy(update => update.Action("DestroyUtilisateurGrid", "Admin"))
            )
)


The filter row is not visible and I don't understand why.

Can anybody help me ?


Alexander Popov
Telerik team
 answered on 27 Feb 2015
7 answers
841 views
I'm trying to get some editor templates in child grids.  They work fine in the parent grid but when I try to add them to the child grid, the .ToClientTemplate() returns invalid Template format.  Not sure what else to do. Thnx


Here's the code :
(Parent grid):
@(Html.Kendo().Grid<PDT.Dashboard.Models.CategoryVM>()
                    .Name("CategoryGrid")
                    .HtmlAttributes(new { @class = "expandable-rows grid-within-grid" })
                    .Editable(editable => { editable.Mode(GridEditMode.InLine); editable.DisplayDeleteConfirmation(false); })
                    .Columns(columns =>
                    {
                        columns.Bound(a => a.CategoryIconId)
                            .Title("Icon")
                            .ClientTemplate("<span class='icon30 gray-icon notes-icon-#= CategoryIconId #'></span>")
                            .EditorTemplateName("EditCategoryIcon")
                        columns.Bound(a => a.CategoryName)
                            .EditorTemplateName("EditCategoryName");
                        columns.Bound(a => a.IsDeleted)
                            .Title("Active")
                            .ClientTemplate("<span> #= IsDeleted ? 'Active' : 'Inactive' #</span>")
                        columns.Bound(a => a.SortOrder)
                            .EditorTemplateName("EditSortOrder")
                        columns.Command(command => { command.Edit().HtmlAttributes(new { title = "Edit" }); }).Width(55);
                    })
                    .Sortable()
                    .Pageable(p => p.PageSizes(new[] { 10, 20, 50, 100 }))
                    .ClientDetailTemplateId("AdminSubCategoryTemplate")
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(20)
                        .Read(read => read.Action("GetCategories", "Permissions"))
                        .Create(create => create.Action("AddCategory", "Permissions"))
                        .Update(update => update.Action("UpdateCategory", "Permissions"))
                        .Model(model => { model.Id(m => m.CategoryId);  })
                                    .Sort(s => { s.Add(m => m.SortOrder).Ascending(); })
                        .Events(e =>
                        {
                            e.Error("categoryErrorHandler");
                        })
                    ))






​ @(Html.Kendo().Grid<PDT.Dashboard.Models.SubCategoryVM>()
        .Name("grid_#=CategoryId#")
        .Editable(editable => { editable.Mode(GridEditMode.InLine); editable.DisplayDeleteConfirmation(false); })
        .ToolBar(tb => tb.Create())
        .Columns(columns =>
        {
            columns.Bound(a => a.SubCategoryName)
                            .EditorTemplateName("EditSubCategoryName");
            columns.Bound(a => a.IsDeleted)
                .Title("Active")
                .ClientTemplate("<span> \\#= IsDeleted ? 'Active' : 'Inactive' \\#</span>")
            columns.Bound(a => a.SortOrder).Width(100);
            columns.Command(command => { command.Edit(); }).Width(70);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(5)
            .Read(read => read.Action("GetSubCategories", "Permissions", new { categoryId = "#=CategoryId#" }))
            .Create(create => create.Action("AddSubCategory", "Permissions", new { parentCategoryId = "#=CategoryId#" }))
            .Update(update => update.Action("UpdateSubCategory", "Permissions"))
            .Model(model =>
            {
                model.Id(m => m.SubCategoryId);
                model.Field(m => m.CategoryId).Editable(false);
            })
            .Sort(s => { s.Add(m => m.SortOrder).Ascending(); })
            .Events(e =>
            {
                e.Error("subcategoryErrorHandler");
            })
        )
        .Pageable()
        .Sortable()
        .ToClientTemplate()
    )


EditCategoryName.cshtml:

<span class="k-widget k-numerictextbox" >
<span class="k-numeric-wrap k-state-default k-expand-padding">
        <input class="k-input text-box single-line" id="CategoryName" name="CategoryName" type="text" value="" data-bind="value:CategoryName">
    </span>
</span>






EditSubCategoryName.cshtml:
<span class="k-widget k-numerictextbox" >
<span class="k-numeric-wrap k-state-default k-expand-padding">
        <input class="k-input text-box single-line" id="SubCategoryName" name="SubCategoryName" type="text" value="" data-bind="value:SubCategoryName">
    </span>
</span>










Kelso
Top achievements
Rank 1
 answered on 26 Feb 2015
4 answers
368 views
I'm migrating a project based on the telerik MVC extensions, over to Kendo, and I'm having problems with an edit form.

It's based on a custom object, which uses data annotations for validation, on a couple of decimal fields:-
[Required(ErrorMessage = "Activity Value is required!")]
       [Range(0, 90000000, ErrorMessage = "Activity Value Cannot be less than zero!")]
       [RegularExpression(@"^\d{1,8}(\.\d{1,4})?$", ErrorMessage = "Please enter a numeric value with up to four decimal places.")]
       public decimal Activity { get; set; }

When a record is inserted, the regular expression validation error message is shown, even though the data entered meets the criteria. The only way to get the form to work is to comment out the regular expression rule. The range validation works fine.

This code worked perfectly using the old MVC extensions grid and pop-up edit form. How can I get this to work using the Kendo grid?
Vladimir Iliev
Telerik team
 answered on 26 Feb 2015
1 answer
330 views
I'm migrating an application from the old Telerik Mvc controls to the latest UI for ASP.NET MVC wrappers.

I have a bunch of unit tests that validated the controller actions that the grid calls for data.  A simple example would be:

<TestMethod()>
Public Sub GetLogEntryData_Passes_Through_Filters_On_Multiple_Columns()
  Dim passedCmd As GridParameters = Nothing
  _adminLogService.Setup(Function(s) s.GetLogEntries(It.IsAny(Of GridParameters))).Returns(_validLogEntries).Callback(Sub(p) passedCmd = p)
  Dim target As New AdminLogController(_adminLogService.Object, Nothing)
  Dim cmd As GridCommand = GridCommand.Parse(1, 10, Nothing, Nothing, "UserName~eq~'test'~and~ControllerName~startswith~'Users'")
  target.GetLogEntryData(cmd)
  Assert.IsNotNull(passedCmd)
  Assert.AreEqual(2, passedCmd.Filters.Count)
End Sub

Now that I have replaced the grids and I'm passing a DataSourceRequest instead, I don't suppose there's a similarly handy function that can replace the GridCommand.Parse statement?

Cheers,
Nick
Rosen
Telerik team
 answered on 26 Feb 2015
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
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
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
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Licensing
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?