Telerik Forums
UI for ASP.NET MVC Forum
1 answer
1.0K+ views

Hi.  I'm trying to run very simple validation for the grid inline edit function. 

 - GridEditMode.InLine

 - Server binding

 - Trying to add "onsubmit" attribute to the "GridForm" form element (it does not work)

Or does DataAnnotation based validation works for this case?  If so, please let me know any sample code for that.  I could only see AJAX version or non-grid version.

Below is my cshtml file:

@using Kendo.Mvc.UI;
@using Kendo.Mvc.Extensions;
@model WebApp.Features.Vendor.Index.Result
@{
    ViewBag.Title = "Vendor Management";
}
<div class="jumbotron">
    <div id="clientsDb">
        @Html.ValidationDiv()
        @(Html.Kendo().Grid((IEnumerable<PayBy.WebApp.Features.Vendor.UiController.Vendor>)Model.Vendors)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.VendorName).Title("Name").Width(30);
            columns.Bound(c => c.IsInternal).Title("Internal").Width(30);
            columns.Bound(c => c.AccountName).Title("Account").Width(50);
            columns.Command(commands => commands.Edit()).Width(30);
        })
        .ToolBar(toolbar => toolbar.Create().Text("Add"))
        .Sortable()
        .Editable(editable => editable.Mode(GridEditMode.InLine))
        .HtmlAttributes(new { style = "height: 480px;" })
        .Scrollable()
        .DataSource(dataSource => dataSource
            .Server()
            .Model(model =>
            {
                model.Id(p => p.Id);
                model.Field(f => f.AccountName).Editable(false);
            })
            .Create("Update", "Vendor")
            .Update("Update", "Vendor")
            .Sort(sort => sort.Add("VendorShortName").Ascending())
        )
        )
    </div>
</div>
<div class="row">
</div>
<script>
    var form = $('#GridForm');
    if (form != null) {
        form.attr('onsubmit', 'return ValidateForm();');
    }
    function ValidateForm()
    {
        alert('validate');
        if ($('#VendorName').val().length == 0) {
            alert('[Name] Required field.');
            return false;
        }
        if ($('#VendorName').val().length > 256) {
            alert('[Name] Maximum 256 letters.');
            return false;
        }
        return true;
    }
</script>

Daniel
Telerik team
 answered on 21 Oct 2015
2 answers
297 views
Hi,

I have a Kendo Grid that I am building dynamically from a `System.Data.DataTable`. I am having issues trying to lock the columns.

I am setting a few columns to locked based on their title as you will see in my code. The boolean check is coming back as true or false where expected and that value is correctly being set in the `.Locked()` property. But the grid is not locking that column, nor is it giving me the `Lockable` option in the column menu.

Please see my code below:

       @model MvcProject.UnitOfWork.ViewModels.Reports.FacilityEquipmentDistributionVm


       @(Html.Kendo().Grid<dynamic>()
       .Name("resultsGrid")
                       .Columns(columns =>
                            {
                                columns.Group(group => group
                                    .Title("Facility Equipment Distribution Report : Date run - " + DateTime.Now.ToShortDateString())
                                    .Columns(header =>
                                    {
                                       
                                        foreach (System.Data.DataColumn column in Model.CombinedTable.Columns)
                                        {
                                            string title = "";
                                            bool showColumn;
                                            
                                            if (Model.ColumnTitles.TryGetValue(column.ColumnName, out title))
                                            {
                                                
                                            }
                                            else
                                            {
                                                title = column.ColumnName;
                                            }

                                            if (Model.ColumnsToShow.TryGetValue(column.ColumnName, out showColumn))
                                            {

                                            }
                                            else
                                            {
                                                showColumn = false;
                                            }

                                            bool lockColumn = (title == "PropertyRef" || title == "PropertyName" || title == "Address" || title == "Prefix" || title == "Floor");
                                            
                                           header.Bound(column.ColumnName)
                                                .Title(title)
                                                .Visible(showColumn)
                                                .Locked(lockColumn)
                                                .Lockable(true)
                                                .Width(title.Length * 8);

                                        }

                                    })
                                );
                            })

                        .HtmlAttributes(new { style = "height: 900px;" })
                            .Pageable(p => p
                                .ButtonCount(5)
                                .PageSizes(true)
                                .Refresh(true)
                            )

                            .Scrollable(s => s.Height("auto").Enabled(true))
                            .Sortable()
                            .Reorderable(reorderable => reorderable.Columns(true))
                            .Filterable()
                            .Groupable()
                            .ColumnMenu()
                            .Resizable(r => r
                                .Columns(true)
                            )
                                .Excel(excel => excel
                                    .FileName("Facility Equipment Distribution.xlsx")
                                    .Filterable(true)
                                    .ProxyURL(Url.Action("_GridExportSave", "Reports"))
                                    .AllPages(true)
                                )
                            .DataSource(d => d
                                .Ajax()
                                
                                .Read(read => read.Action("_FacilityEquipmentDistributionResults_Read", "Reports").Data("Genesis.Reports.Space.Search.getPaginationData"))
                                    .ServerOperation(true)
                                    .PageSize(20)
                                )
                                .ToolBar(tools =>
                                {
                                    tools.Pdf();
                                    tools.Excel();
                                })
        //PDF removed for now until it is patched
                                .Pdf(pdf => pdf
                                     .AllPages()
                                    .FileName("FacilityEquipmentDistribution.pdf")
                                    .ProxyURL(Url.Action("_GridExportSave", "Reports"))
                                )
                                //.Events(events => events.DataBound("Genesis.Reports.Space.Search.loadTT"))

)

Any help would be much appreciated.

Kind Regards,
Gareth
Gareth
Top achievements
Rank 1
 answered on 20 Oct 2015
1 answer
106 views

Is there a demo of how to connect a chart to the selected row(s) of a grid?  Basicly I have a grid and when the user selects a row(s) I want to have the selected data update a chart on the page.

Thanks,

Erik

Iliana Dyankova
Telerik team
 answered on 20 Oct 2015
1 answer
481 views

I am trying to use a datepicker in a grid column that utilizes InCell editing.  The problem I am having is that the datepicker appears to revert back to the specified default value after I remove the focus from the datepicker cell into another cell.  Another interesting thing to note is that I can click back into the datepicker cell that I changed and the datepicker will once again show the correct date that I changed the cell too.  Any ideas what causes this behavior?

Here is the date snippet from my viewmodel:

[DisplayName("Month/Year")]
[DisplayFormat(DataFormatString = "{0:MMMM yyyy}")]
[DataType(DataType.Date)]
[Required]
public DateTime FOBDate { get; set; }

 

Here is my Date.cshtml code:

@model DateTime?
 
@(Html.Kendo().DatePickerFor(m => m)
    .Name("fobpricedate")
    .Format("MMMM yyyy")
    .Start(CalendarView.Year)
    .Depth(CalendarView.Year)
)

 

And here is my view that contains the grid:

@(Html.Kendo().Grid<TestMACPortal.Models.FOBViewModel>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(c => c.Category).ClientTemplate("#=Category.CategoryName#"); //.EditorTemplateName("ProductCategory");
                    columns.Bound(c => c.SKU_Name);
                    columns.Bound(c => c.MaterialNumber);
                    columns.Bound(c => c.Company).ClientTemplate("#=Company.CompanyName#");
                    columns.Bound(c => c.FOBDate).EditorTemplateName("Date");
                    columns.Bound(c => c.Price).EditorTemplateName("Price");
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Create();
                    //toolbar.Save();
                })
                .Editable(editable => editable.Mode(GridEditMode.InCell))
                .HtmlAttributes(new { style = "height: 500px;" })
                .Scrollable()
                .Sortable()
                .Groupable()
                .Resizable(resize => resize.Columns(true))
                //.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Batch(true)
                    .ServerOperation(false)
                    .Events(events => events.Error("error_handler"))
                    .Model(model =>
                    {
                        model.Id(c => c.FOBID);
                        model.Field(c => c.FOBID).Editable(false);
                        model.Field(c => c.Category).DefaultValue(ViewData["defaultCategory"] as TestMACPortal.Models.ProductCategoryViewModel);
                        model.Field(c => c.Company).DefaultValue(ViewData["defaultCompany"] as TestMACPortal.Models.CompanyViewModel);
                        model.Field(c => c.FOBDate).DefaultValue(DateTime.Today);
                    })
                    //.Destroy("Editing_Destroy", "FOB")
                    .Read(read =>
                    {
                        read.Action("GetFOBs", "FOB");
                    })
                //.Create("CreateFOB", "FOB")
                //.Update("UpdateFOB", "FOB")
                )
        )

 

 

 

 

Georgi Krustev
Telerik team
 answered on 20 Oct 2015
4 answers
159 views
Hi,
is there a way to use a Kendo Grid with polymorphic items and Popup editing?

I'd like to define a base class BaseViewModel with some common properties and subclasses FirstViewModel and SecondViewModel with more specific properties. The Grid is bound to BaseViewModel, but in the Popup Editor I'd like to edit the subclasses. The controller produces an IEnumerable containing FirstViewModels and SecondViewModels.

I have defined EditorTemplates for FirstViewModel and SecondViewModel but the Model which is passed to when editing is always of type BaseViewModel.
Any suggestions?

Kind regards,
Thomas
Vladimir Iliev
Telerik team
 answered on 20 Oct 2015
2 answers
141 views

I have a grid control which is bound to the model I have passed it in the view (local data):

 HireReport.cshml

 

    @model ReportingPortalWeb.Models.HireReportViewModel

     @(Html.Kendo().Grid(Model.StockReport)
          .Name("grid")
           .Columns(columns =>
                     {
                              columns.Bound(p => p.SohQty).Title("Quantity").Visible(Model.StockReport.Sum(t => t.SohQty) > 0);

                              ...

 

I want to add the export to excel function but this seems limited to remote data

     .ToolBar(tools => tools.Excel())

    ...

Is there no way to bind this to the local model data?

 

 â€‹

 

Graham
Top achievements
Rank 1
 answered on 20 Oct 2015
1 answer
148 views

I would like to implement a drill through type action on a bar charts series.

Here is what i have so far:

@(Html.Kendo().Chart<BetaSMTRApp.Business.PrivateReportCardCumulativeInvestments>()
                            .Name("ChartInvestmentCumulations_" + item.FUND_INT.ToString())
                            //.Title("Cumulative Investments")
                            .Legend(legend => legend
                                        .Position(ChartLegendPosition.Top)
                                    )
                            .DataSource(dataSource => dataSource
                                            .Read(read => read.Action("GetCumulativeInvestments", "PrivateReportCard", new { fundInt = item.FUND_INT }))
                                          )
 
                            .Series(series =>
                            {
                                series.Column(model => model.Commitments).Name("Commitments").Color("Red");
                                series.Column(model => model.Distributions).Name("Distributions").Color("Green");
                                series.Column(model => model.Draw_Down).Name("DrawDowns").Color("Yellow");
                                series.Column(model => model.Fees).Name("Fees").Color("Brown");
                            })
                            .CategoryAxis(axis => axis
                                .Categories(model => model.YearCategory)
 
                            )
                            .ValueAxis(axis => axis.Numeric()
                                .Labels(labels => labels
                                    .Format("${0}")
                                )
                            )
                            .Tooltip(tooltip => tooltip
                                    .Visible(true)
                                    .Template("#= series.name #: #= value #")
                            )
                            .Events (events=>events.SeriesClick("onSeriesClick"))
 
)

 

Javascript/JQuery

function onSeriesClick(e) {
    $("#window").data("kendoWindow").open();
    $("#undo").hide();
};

Kendo Window

@(Html.Kendo().Window()
    .Name("window")
    .Title("About Alvar Aalto")
    .Content(@<text>
        <div class="armchair">
            <img src="@Url.Content("~/content/web/window/armchair-402.png")"
                 alt="Artek Alvar Aalto - Armchair 402" />
            Artek Alvar Aalto - Armchair 402
        </div>
 
        <p>
            Alvar Aalto is one of the greatest names in modern architecture and design.
            Glassblowers at the iittala factory still meticulously handcraft the legendary
            vases that are variations on one theme, fluid organic shapes that let the end user
            ecide the use. Interpretations of the shape in new colors and materials add to the
            growing Alvar Aalto Collection that remains true to his original design.
        </p>
 
        <p>
            Born Hugo Alvar Henrik Aalto (February 3, 1898 - May 11, 1976) in Kuortane, Finland,
            was noted for his humanistic approach to modernism. He studied architecture at the
            Helsinki University of Technology from 1916 to 1921. In 1924 he married architect
            Aino Marsio.
        </p>
 
        <p>
            Alvar Aalto was one of the first and most influential architects of the Scandinavian
            modern movement, and a member of the Congres Internationaux d'Architecture Moderne.
            Major architectural works include the Finlandia Hall in Helsinki, Finland,
            and the campus of Helsinki University of Technology.
        </p>
 
        <p>
            Source:
            <a href="http://www.aalto.com/about-alvar-aalto.html" title="About Alvar Aalto">www.aalto.com</a>
        </p>
    </text>)
    .Draggable()
    .Resizable()
    .Visible(false)
    .Width(600)
    .Actions(actions => actions.Pin().Minimize().Maximize().Close())
)

Oh and yes i know that the window is displaying static text... i will eventually be putting in a Grid to display the detail records (and question #2 relates to it) 

 

Here are my 2 issues/questions:

1. The window does pop up when i click on a series.  However the page behind it goes white and only the contents of the window appear.  Is there a way to allow the calling web page still appear (and not go blank).

2. In the javascript call to open the window is it possible to pass the contents of e to it (e contains parameter values that i want to use in the pop up window).

Thanks,

Corey

Daniel
Telerik team
 answered on 20 Oct 2015
1 answer
454 views

I have a kendo grid that gets data remotely (because I use the export to excel functionality). The column headers are bound to my model which is passed as empty before the data source request gets the populated one.

    @model ReportingPortalWeb.Models.HireReportViewModel

     @(Html.Kendo().Grid<StockReport>()
                  .Name("grid")
                  .Columns(columns =>
                  {
                      columns.Bound(p => p.SohQty).Title("Quantity");
                      columns.Bound(p => p.StockName);
                      ​...
                      columns.Bound(p => p.SiteAddress3);
                      columns.Bound(p => p.PostCode);
                  })
                  .ToolBar(tools => tools.Excel())
                  .Groupable()
                  .Excel(excel => excel
                      .FileName("Kendo UI Grid Export.xlsx")
                      .Filterable(true)
                      .ProxyURL(Url.Action("CustomReport_Data", "Reports"))
                  )
                  .DataSource(dataSource => dataSource
                      .Ajax()
                                        .Read(read => read.Action("CustomReport_Data", "Reports").Data("GetData")))
                  .Pageable()
                  .Sortable()
                  .Scrollable()
                  .Filterable()
                  .HtmlAttributes(new {style = "height:550px;"})
                  )

Before having to use the excel export I passed the data when the gird was created and I could hide a column easily by doing something like 

     columns.Bound(p => p.PrCode).Visible(Model.StockReport.Count(t => t.PrCode.Any()) > 0);

 

now that I am remotely fetching the data instead, is there a data on load event that I can use to hide the columns in my report that don't have any data in them?

 

 

Radoslav
Telerik team
 answered on 20 Oct 2015
2 answers
214 views

Hello,

I have seen examples of confirmation boxes applied to inline / cell editing.

How can I display a confirmation ("saved successfully" or "not saved successfully" using something like notification widget if the grid batch editing mode is used?

The Save command is calling the controller action for Save and returns a JSON request as a response. But I don't know yet to get the additional notifaction displayed.

Yours

Stephan

 

Boyan Dimitrov
Telerik team
 answered on 19 Oct 2015
4 answers
451 views
Hi,

I want to display customised tooltip on hover in one of the column in grid.
My requirement is:
I have Person's grid where I am displaying first name, last name, birth date details. There is an another column say "Go To". When user mousehover on that particular column's cells, I want to display tooltip template. In which there will be few links (addresses, emails, phones etc.) with person id.
Based on the person's Id the link in tooltip should be constructed, So clicking on it navigates to person details.

How to do this? I have searched on net but couldn't find exact or nearer example.
Need help.

Thanks,
Nirav
Blake
Top achievements
Rank 2
 answered on 19 Oct 2015
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?