Telerik Forums
UI for ASP.NET MVC Forum
5 answers
805 views

I started working on a new asp.net core application and I have to use also telerik. The project was started by someone else and now I have to change how the scripts are loaded. I have installed the kendo-ui package with bower.

The application is using the kendo.all.min.js but I can not find it in the kendo-ui package. How do I generate it? Is there a page that provides instruction on how to created it?

Dimitar
Telerik team
 answered on 14 Mar 2018
3 answers
2.8K+ views

Hi,

I'm aggregating some of my columns, and using the ClientGroupFooterTemplate and aligning some of them using:

<div style='text-align:right'>#= kendo.format('{0:C}', sum)#</div>

 

because the HtmlAttributes doesn't seem to work:

.HtmlAttributes(new { style = "text-align:right;" });

 

So the issue I'm facing is when i Export to Excel it prints the "<div style='text-align:right'></div>" which is unneeded and a massive pain as the Data doesn't format correctly.

 

Is there a better way to achieve what i need and not printing the div tag in the exported excel file?

 

Thanks,
Lee.

 

 

 

 

 

 

Alex Hajigeorgieva
Telerik team
 answered on 14 Mar 2018
1 answer
535 views

Hi i have created a dynamic grid in MVC. the grid datasource will be setup in javascript. 

everything works fine in creating the grid and populating the grid data if there is no grouping

However, if i want to group the record and calculate the total.The total value became "undefined".

Also, i found that in the "aggregate" in DataSourceRequest is always null. is it normal ?

@(Html.Kendo().Grid<dynamic>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.LoadSettings((List<GridColumnSettings>)TempData["ColumnSettings"]);
    })
    .Events(e =>
    {
        e.DataBound("DataBound");
        e.DataBinding("DataBinding");
        e.ColumnMenuInit("ColumnMenuInit");
    })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .ServerOperation(false)
        .PageSize(50)
        .Aggregates(agg => {
            var ds = (List<System.Data.DataColumn>)TempData["dataAgg"];
                if (ds != null && ds.Count() > 0)
                {
                    foreach (System.Data.DataColumn column in (List<System.Data.DataColumn>)TempData["dataAgg"])
                    {
                        agg.Add(column.ColumnName, column.DataType).Sum().Count().Max().Min();
                    }
                }
        })
        .Model
        (model =>
            {
                var ds = (List<System.Data.DataColumn>)TempData["dataType"];
                if (ds != null && ds.Count() > 0)
                {
                    foreach (System.Data.DataColumn column in (List<System.Data.DataColumn>)TempData["dataType"])
                    {
                        model.Field(column.ColumnName, column.DataType);
                    }
                }
            }
            )
    )
    .Events(e => e.ExcelExport("ExcelExport"))
    .ColumnMenu(menu => menu.Columns(false))
    .Filterable(f => f.Extra(false)
                    .Operators(operators => operators
                        .ForString(str => str.Clear()
                        .Contains("Contains")
                        .StartsWith("Starts With")
                        .EndsWith("Ends With")
                        .IsEqualTo("Exact Match"))
                        .ForNumber(num => num.Clear()
                        .IsEqualTo("Equals")
                        .IsGreaterThan("Greater Than")
                        .IsLessThan("Less Than"))
                        ))
    .Groupable()
    .Sortable(sort => sort.SortMode(GridSortMode.MultipleColumn))
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
     .Excel(excel => excel
            .FileName("MyGrid.xlsx")
            .AllPages(true)
            )
    .Scrollable(s => s.Enabled(true).Height("auto"))
    .NoRecords("There is no record")
    .HtmlAttributes(new { style = "min-width:200px;max-width:900px;" })
 )

 

the grid data will be populated from the front end 

var ds = new kendo.data.DataSource({
            type: "aspnetmvc-ajax",
            transport: {
                read: "/GetGridData?DataUid=" + DataUid,
                dataType: "json"
            },
            schema: {
                data: "Data",
                total: "Total",
                errors: "Errors"
            },
            pageSize: 20,
            serverGrouping: true,
            serverPaging: true,
            serverFiltering: true,
            serverSorting: true,
       });
        var grid = $("#grid").data("kendoGrid");
 
        grid.setDataSource(ds);

 

Wind
Top achievements
Rank 1
 answered on 14 Mar 2018
11 answers
1.3K+ views

I've been trying to implement cell-based editing into my grid. It does work in a fashion, in that I can edit the current values present in the grid and they do save when clicking the Save Changes button. However, it does not appear to be firing the Update function correctly, which points to a function in the Controller. I know the grid is able to fire events for Read since I've applied a filter which uses a function in the Controller, and it's able to call that function without problems. It just doesn't seem to fire the Update function.

Below is the code for the table;

@{Layout = null;}
 
 
@(Html.Kendo().Grid<FiveSReporting.Models.ViewModels.SchedulingViewModel>()
      .Name("Schedule")
      .Columns(columns =>
      {
          columns.Bound(c => c.LineName);
          columns.Bound(c => c.WeekOfFirst);
          columns.Bound(c => c.WeeksBetweenEach);
      })
      .ToolBar(t => { t.Save(); })
      .Pageable()
      .Editable(e => e.Mode(GridEditMode.InCell))
      .Sortable(sortable =>
      {
          sortable.SortMode(GridSortMode.SingleColumn);
      })
      .Scrollable(scrollable => scrollable.Enabled(false))
      .DataSource(dataSource => dataSource
          .Ajax()
          .Batch(true)
          .ServerOperation(false)
          .Events(e => e.Error("error_handler"))
              .Model(m => { m.Id(s => s.ID); m.Field(s => s.LineName).Editable(false); })
          .Update(update => update.Action("Schedule_Write", "ScheduleAdminTwo"))
          .Read(read => read.Action("Schedule_Read", "ScheduleAdminTwo")
          .Data("getSchedule"))
      )
      .AutoBind(false)
)

 

I've also found that when clicking on the Cancel Changes button that it will throw an error to the console, and subsequent attempts to navigate on the grid also throw errors.This occurs when you click the Cancel Changes button just after clicking the Save Changes button. See attached screenshot for details.

Thank you ahead of time for your assistance.

Denise
Top achievements
Rank 1
 answered on 13 Mar 2018
1 answer
133 views

Hi,I have something like this in my _LayoutStandard.html for an ASP.NET MVC5 site:

@(Html.Kendo().Menu().Name("tdtMenu").Items(lvl1 =>
{
  lvl1.Add()
      .ImageUrl(Url.Content("~/Content/Images/tools.png"))
      .Items(lvl2 =>
      {
          lvl2.Add().Text("Server info").Action("About", "Foo");
          lvl2.Add().Text("Change my password").Action("Manage", "Account");
          lvl2.Add().Text("Administration").Action("Index", "Admin");
          lvl2.Add().Text("Testpages").Items(lvl3 =>
          {
              lvl3.Add().Text("Testpage - Fitting").Action("FittingTest", "Fitting");
              lvl3.Add().Text("Testpage - SignalR").Action("Index", "Foo");
              lvl3.Add().Text("Testpage - Obsolete").Action("Project", "Overview");
          });
          lvl2.Add().Text("Projects").Action("Overview", "Project");
      });
}).Events(e => e.Select("TDT.MenuSelect")))

 

I have noticed, that the Action() calls lead to calling the controller constructors. Why is that? Isn't that a performance issue?

Thank you for more information on this!

Caecilia
Top achievements
Rank 1
 answered on 13 Mar 2018
1 answer
105 views
     Anyone know of a way I can search for a record and programmatically start inline editing a record that might be on another server side page of my grid? e.g. I have a grid that gets it's data from entity framework using linq. It has pagination enabled and gets each page from the server as requested. Is there a good way to search for a specific record and navigate to the page it's on and start inline editing it?
Preslav
Telerik team
 answered on 13 Mar 2018
3 answers
303 views

I have tried setting up a pivot grid following the demos at http://demos.telerik.com/aspnet-mvc/pivotgrid/local-flat-data-binding and http://demos.telerik.com/aspnet-mvc/pivotgrid/remote-flat-data-binding.

 

using this model

public class FundModel
{
    public string AssetClass { get; set; }
    public DateTime ReportDate { get; set; }
    public decimal? AssetsStart { get; set; }
}
 

 and this controller

 

public ActionResult TestView()
{
    return View(
       // GetAdvisors()
       GetFunds()
        );
}
 
 
private IEnumerable<FundModel> GetFunds()
{
    IEnumerable<FundModel> funds;
    using (var context = new EPFRUI_Entities())
    {
        funds = context.vwDailyFundFlowDetails.Take(300).Select(x => new FundModel
        {
            AssetClass = x.FundName,
            ReportDate = x.ReportDate,
            AssetsStart = x.AssetsStart
        }).ToList();
    }
    return funds;
}

 â€‹I am passing in my data to this pivot grid based on the demo code

 

    @(Html.Kendo().PivotConfigurator()
    .Name("configurator")
    .Height(570)
)
 
@(Html.Kendo().PivotGrid<FundModel>()
    .Name("pivotgrid")
    .Configurator("#configurator")
    .ColumnWidth(120)
    .Height(570)
    .BindTo(Model)
    .DataSource(dataSource => dataSource
        .Ajax()
        .Schema(schema => schema
            .Model(m => m.Field("CategoryName", typeof(string)).From("Category.CategoryName"))
            .Cube(cube => cube
                .Dimensions(dimensions => {
                    dimensions.Add(model => model.AssetsStart).Caption("Assets Start");
                    dimensions.Add("CategoryName").Caption("All Categories");
                    dimensions.Add(model => model.AssetClass).Caption("AssetClass");
                })
            .Measures(measures => measures.Add("AssetsStart").Field(model => model.AssetsStart).AggregateName("count"))
            ))
        .Columns(columns =>
        {
            columns.Add("CategoryName").Expand(true);
            columns.Add("AssetClass");
        })
        .Rows(rows => rows.Add("AssetClass").Expand(true))
        .Measures(measures => measures.Values("Sum"))
        .Events(e => e.Error("onError"))
    )
)

 

Which is getting me a single long line when I run the program and navigate to the view. I have included what shows up in the attached image.

 

I have also tried setting this up with remote binding and got the same view.

 

Am I missing an obvious step here? I debugged it and the model has data when the pivot grid is called, and no errors are coming back from the pivotgrid

 

 

 

Stefan
Telerik team
 answered on 13 Mar 2018
2 answers
262 views

Hi,

When using the Export to Excel is only works for the current page, is there anyway to export the whole table (dataset)?

Thanks,
Lee.

Lee
Top achievements
Rank 1
Veteran
 answered on 12 Mar 2018
2 answers
1.0K+ views

First off, I am very new to MVC, so apologies in advance.

I don't know what I'm missing, but I have an enum type:

 public enum ClientStatus
    {
        [Description("Unknown")]
        Unknown = 0,
        [Description("Normal")]
        Normal = 1,
        [Description("Legal Hold")]
        LegalHold = 200
    }

There is a database field which holds the integer value corresponding to the enum type.  For my grid, I have:

Html.Kendo().Grid<IST.DocstorClient.Database.cache_dsl_client>()
                    .Name("grid")
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.dsl_client_id).Title("Client ID").EditorTemplateName("#dsl_client_id#");
                        columns.Bound(o => o.dsl_client_name).Title("Client Name");
                        columns.Bound(o => o.dsl_client_description).Title("Description");
                        columns.Bound(o => o.dsl_client_status).Title("Status").ClientTemplate("#=status_name#").EditorTemplateName("ClientStatus");
                        columns.Command(cmd => cmd.Destroy());
                    })
                    .ToolBar(toolbar =>
                    {
                        toolbar.Create();
                        toolbar.Save();
                    })
                    .Editable(editable => editable.Mode(GridEditMode.InCell))
                    .Pageable()
                    .Navigatable()
                    .PersistSelection()
                    .Sortable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .PageSize(10)
                        .Model(model =>
                        {
                            model.Id(p => p.dsl_client_id);
                            model.Field(p => p.dsl_client_id).Editable(false);
                        })
                        .Events(events => events.Error("dsr_error_handler"))
                        .Read("Editing_Read", "Client")
                        .Create("Editing_Create", "Client")
                        .Update("Editing_Update", "Client")
                        .Destroy("Editing_Destroy", "Client")

 

The item in question here is the column for dsl_client_status, which is defined as a byte? type in the Entity Framework definitions.

I also have a dropdown definition in Shared/EditorTemplates:

@(Html.Kendo().DropDownListFor(m => m)
   .Name("ClientStatus")
   .DataTextField("Text")
   .DataValueField("Value")
   .BindTo(EnumHelper.GetSelectList(typeof(IST.DocstorClient.Data.ClientStatus)))
   .OptionLabel("Select Status")
   .Value(((int)Model).ToString())
  )

 

I have been through a lot of iterations of different things, this is just the state things are in at the moment.

When I click on the cell to edit, I do get the dropdown list, but it is defaulted to the "Select Status", as if there is no value assigned.  I can then change the dropdown value, but the database value never gets updated.  If I click on it again, the value I changed to shows on the dropdown.

For example:

initial value is "Unknown".  
I click to edit, the dropdown list defaults to "Select Status".  
I change to "Normal" and click Save Changes. Text still shows as "Unknown".  
I click to edit again and the dropdown is defaulted to "Normal"

I've been scouring forums and blogs for days, trying all manner of suggestions, all to no avail.  I find it hard to believe that this is that difficult a task to achieve, so I gotta think I'm missing something simple here.

Dimitar
Telerik team
 answered on 12 Mar 2018
1 answer
162 views

We are trying to make to make our Grid date columns have the verbiage and filter options of "From" and "To". Our hope was that after updating them within the razor syntax we could still use the "AND OR" values. It appears to remove that option after we have to run the ".Operators(operators => operators.ForDate(d => d.Clear()".

 

Is there something we are doing wrong? When seem to need to run the ".Clear()" to remove other filter options but now we only have one value we can enter. Either being "To" or "From" but not being able to do "To: (n)" [AND | OR] From:".  Is this not possible if we are customizing the filters or is there a different route we can take to acomplish this?

 

-Thanks-

Code Example:

").Filterable(filterable => filterable.Extra(false).Operators(operators => operators.ForDate(d => d.Clear().IsLessThanOrEqualTo("To").IsGreaterThanOrEqualTo("From")))

 

Stefan
Telerik team
 answered on 12 Mar 2018
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
+? more
Top users last month
Simon
Top achievements
Rank 2
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
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?