Telerik Forums
UI for ASP.NET MVC Forum
3 answers
880 views

I'm trying the grouping in Grid I want to display the sum of the column as ClientGroupHeaderColumnTemplate  or ClientHeaderTemplate but doesn't  seem to be working, it only shows as a ClientFooterTemplate. :

@(Html.Kendo().Grid<Models.DepartmentSummaryView> ()
        .Name("grid")
        .HtmlAttributes(new { style = " height:700px !important;" })
        .Columns(columns =>
        {
            columns.Bound(p => p.DepartmentNo).Width(150).ClientGroupHeaderTemplate("Department: #= value # (Products: #= count#)");
            columns.Bound(p => p.DepartmentName).Width(150).ClientGroupHeaderTemplate("Department: #= value # (Products: #= count#)");
            columns.Bound(p => p.ProductNo).Width(150).ClientGroupHeaderTemplate("Product: #= value # (Count: #= count #)");
            columns.Bound(p => p.ProductName).Width(150);
            columns.Bound(p => p.SKU).Width(150);
            columns.Bound(p => p.Qty).Width(150).ClientGroupHeaderColumnTemplate("Sum: #= sum #").ClientFooterTemplate("Sum: #= sum #");
        })
        .Filterable(filterable => filterable.Extra(false)
        //.Mode(GridFilterMode.Row)
        .Operators(operators => operators
        .ForString(str => str.Clear()
        .StartsWith("Starts with")
        .EndsWith("Ends with")
        .IsEqualTo("Is equal to")
        .IsNotEqualTo("Is not equal to")
        .Contains("Contains")
        .DoesNotContain("Doesn't contain")
        )))
        //.Pageable()
        .Navigatable()
        .AutoBind(false)
        .Sortable()
        .Groupable()
        .Events(events => events.DataBound("onDataBound"))
        .Reorderable(reorderable => reorderable.Columns(true))
        .DataSource(dataSource => dataSource
        .Custom()
        .Schema(schema =>
        {
            schema.Data("Data");
            schema.Total("Total");
        })
        .Events(events => events.Sync("sync_handler"))
        .Group(groups => groups.Add(p => p.DepartmentNo))
        .Aggregates(aggregates =>
        {
            aggregates.Add(p => p.DepartmentNo).Count();
            aggregates.Add(p => p.DepartmentName).Count();
            aggregates.Add(p => p.ProductNo).Count();
            aggregates.Add(p => p.SKU).Count();
            aggregates.Add(p => p.Qty).Sum();
        })
        .Transport(transport =>
        {
 
            transport.Read(read =>
                read.Url("/api/enquiries/departmentsummary)
                .DataType("json")
 
                .Type(HttpVerbs.Get)
                );
                            transport.Create(create =>
                create.Url(Base.APIHostAddress + "/api/enquiries/post")
                .DataType("json")
                .Type(HttpVerbs.Post)
                .ContentType("application/json; charset=utf-8")
 
                );
                        
                transport.ParameterMap("parameterMap");
        })
        )
)

 

Konstantin Dikov
Telerik team
 answered on 15 Nov 2018
1 answer
220 views

I have got a problem where my grid columns expect a detailed name ("CityFrom" and "CityTo" - those are strings), but a method returns "Name" property. How can I map the result to the columns without duplicating the code?

Here is grid:

@(Html.Kendo().Grid<RouteDto>()
.Name("route-grid")
.Columns(cfg =>
{
    cfg.Bound(m => m.CityFrom)
    .Title("City From")
    .Width(150)
    .Filterable(f =>
        f.Multi(true).DataSource(ds =>
            ds.Read(r =>
                r.Action("GetCities", "City")
            )
        )
    );
    cfg.Bound(m => m.CityTo)
    .Title("City To")
    .Width(150)
    .Filterable(f =>
        f.Multi(true).DataSource(ds =>
            ds.Read(r =>
                r.Action("GetCities", "City")
            )
        )
    );
}))

 

Here is method:

public ActionResult GetCities()
{
    var cities = _cityService.GetCities().Select(c => new { c.Name }).ToList();
    return Json(cities, JsonRequestBehavior.AllowGet);
}

Error I am getting is in console:

Uncaught ReferenceError: CityFrom is not defined
Uncaught ReferenceError: CityTo is not defined

 

On grid I could use .DataTextField("Name"), but I don't have this option here. Both filters have got the same set of values - cities from database. Any ideas what can I do elegantly here?

Georgi
Telerik team
 answered on 15 Nov 2018
3 answers
821 views

Hi,

I was wondering if there is a way to accomplish the toolbar functionality in a TreeList as shown for this example in a Grid: Grid / Toolbar template

We need a filtering textbox in the toolbar, that filters the items when the input has changed.

 In the pages with Grid's I use buttons with icons from Font Awesome in the Toolbar, in the TreeList I only seem to be able to add buttons via Custom:

 

.Toolbar(toolbar =>
    {
        toolbar.Custom().Name("addfieldbutton").Text("Veld toevoegen");
        toolbar.Custom().Name("addfolderbutton").Text("Folder toevoegen");
    })

 

It would be nice to keep the design the same when using a TreeList.

 Here's my Toolbar for a grid.

 

.ToolBar(toolbar =>
{
    toolbar.Template(
        @<text>
            @(Html.Kendo().Button()
                .Name("ButtonAddProperty")
                .HtmlAttributes(new { type = "k-button" })
                .Content("Property toevoegen")
                .SpriteCssClass("fa fa-plus")
                .Events(e => e.Click("onCreateProperty"))
            )
        </text>);
})

 

Best regards,

Ronald

 

Tsvetina
Telerik team
 answered on 14 Nov 2018
6 answers
232 views
Is there a way to apply a row template to the TreeList? I haven't seen anything in the examples for this. I am trying to convert a Grid to a TreeList, and I would like to reuse my RowTemplate functionality, if possible.

Thanks!
Jason
Konstantin Dikov
Telerik team
 answered on 14 Nov 2018
4 answers
977 views

Is there any way to disable date by both?  Such as to disable it by all Tuesdays and Thursdays in addition to by a list of specific dates recorded in the database?

I see it how to disable date picker by days of weeks or by a list of specific dates at the demo.   I found the example of the way to disable weekends and dates specified(holidays). But the not finding a solution for the case that I need it to be implemented.

Thank you.

Masa
Top achievements
Rank 1
 answered on 13 Nov 2018
8 answers
691 views

Hello,

My widgets just stopped working!  I am getting the error "Script5009 Kendo not defined".  It seems the browser does not know what to do with the widgets.  I am not getting any errors otherwise.

I am running version 2018 3.0727.

Should I rerun the ProgressControlPanelSetup_2018_3_0727.exe to reinstall?

Thanks for your help!

Carolyn

Marin Bratanov
Telerik team
 answered on 13 Nov 2018
3 answers
435 views

Hello,

I am trying to implement a dropdownlist in a grid popupedit, that select Users from Azure Active Directory. I access the Azure Active Directoty with the Graph Api, so that I always get only a part of the users in the controller to return to the dropdownlist.

The controller sends the data of the users as SelectListItems (Text: Lastname, Firstname; Value: E-Mail).

The selection of a user in a new record works fine and the email address is saved in the database.

But if I want to edit this record, the dropdownlist is empty, because the dropdownlist needs the value for "Text" the Lastname and Firstname.

Is it possible to insert a value for Text and Value in the DropDownList, when editing a record?

Joana
Telerik team
 answered on 13 Nov 2018
4 answers
1.2K+ views

I'm trying to add a foreign key column in my grid. I have a backups table that has a pc_id column. I also have a pc table with pc_id and pc_name columns. Right now, my grid is displaying the pc_id because that is the value that is stored in the backups table. However, I want the grid to display the pc_name.

Index.cshtml:

@{
    ViewBag.Title = "Backup Dashboard";
}
 
@model IEnumerable<MayetDashboard.Models.backup>
 
<h1>Backup</h1>
 
@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.backup_id).Title("Backup ID");
        columns.Bound(c => c.pc_id).Title("PC ID");
        //columns.ForeignKey(c => c.pc_id, (System.Collections.IEnumerable)ViewData["pc"], "pc_id", "pc_name").Title("PC ID");
        columns.Bound(c => c.log_file).Title("Log File").Hidden(true);
        columns.Bound(c => c.backup_date).Title("Backup Date");
        columns.Bound(c => c.backup_job).Title("Backup Job");
        columns.Bound(c => c.backup_result).Title("Backup Result");
        columns.Bound(c => c.backup_text).Title("Backup Text").Hidden(true);
        columns.Bound(c => c.stamp_date).Title("Stamp Date");
        columns.Command(command => { command.Destroy(); });
    })
    .Pageable()
    .Filterable(filter =>
    {
        filter.Extra(false);
        filter.Operators(op =>
        {
            op.ForString(str =>
            {
                str.Clear().Contains("Contains");
            });
        });
    })
    .DataSource(dataSource => dataSource
    .Server()
    .Model(model =>
    {
        model.Id(p => p.backup_id);
        model.Field(p => p.pc_id).DefaultValue(1);
    })
    .Read(read => read.Action("Index", "Backup"))
    .Destroy("backups_Destroy", "Backup")
    )
)

 

BackupController.cs:

using System;
using System.Linq;
using System.Data;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Kendo.Mvc.Extensions;
using MayetDashboard.Models;
using System.Data.Entity;
using System.IO;
using Telerik.Windows.Zip;
using System.IO.Compression;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using Kendo.Mvc.UI;
 
namespace MayetDashboard.Controllers
{
    public class BackupService : IDisposable
    {
        private mayet_dashboardEntities1 db;
 
        public BackupService(mayet_dashboardEntities1 db)
        {
            this.db = db;
        }
 
        public IEnumerable<backup> Read()
        {
            return db.backups;
        }
 
        public void Destroy(backup backup)
        {
            var entity = new backup
            {
                backup_id = backup.backup_id,
                pc_id = backup.pc_id,
                log_file = backup.log_file,
                backup_date = backup.backup_date,
                backup_job = backup.backup_job,
                backup_result = backup.backup_result,
                backup_text = backup.backup_text,
                stamp_date = backup.stamp_date,
            };
 
            db.backups.Attach(entity);
            db.backups.Remove(entity);
            db.SaveChanges();
        }
 
        public void Dispose()
        {
            db.Dispose();
        }
    }
 
    public class BackupController : Controller
    {
        private BackupService backupService;
 
        public BackupController()
        {
            backupService = new BackupService(new mayet_dashboardEntities1());
        }
 
        protected override void Dispose(bool disposing)
        {
            backupService.Dispose();
 
            base.Dispose(disposing);
        }
 
        public ActionResult Index()
        {
            return View(backupService.Read());
        }
 
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Backups_Destroy(backup backup)
        {
            RouteValueDictionary routeValues;
 
            backupService.Destroy(backup);
 
            routeValues = this.GridRouteValues();
 
            return RedirectToAction("Index", routeValues);
        }
 
        public void Update()
        {
            //GET ALL ZIPPED UP LOG FILES
            string[] arrayLogs = Directory.GetFiles(@"\\192.168.222.245\Backups\logs", "*.zip", System.IO.SearchOption.AllDirectories);
            var countLogs = arrayLogs.Length;
            string tempFolder = @"C:\temp\";
            for (int i = 0; i < countLogs; i++)
            {
                string logItem = arrayLogs[i];
                var logDirectory = new FileInfo(logItem).DirectoryName;
                //ZipFile.ExtractToDirectory(logItem, @"C:\temp\");
                using (System.IO.Compression.ZipArchive archive = ZipFile.OpenRead(logItem))
                {
                    foreach (System.IO.Compression.ZipArchiveEntry entry in archive.Entries)
                    {
                        if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
                        {
                            entry.ExtractToFile(Path.Combine(tempFolder, entry.FullName), true);
                        }
                    }
                }
 
                //BACKUP_TEXT COLUMN
                string backupText = System.IO.File.ReadAllText(tempFolder + "LogFile.txt");
                string resultBackupText = Regex.Replace(backupText, @"^\s+$[\r\n]*", string.Empty, RegexOptions.Multiline);
 
                //PC_ID COLUMN
                int startPosPcId = resultBackupText.LastIndexOf("Computer/Account: ") + "Computer/Account: ".Length;
                int lengthPcId = resultBackupText.IndexOf(" /") - startPosPcId;
                string subPcId = resultBackupText.Substring(startPosPcId, lengthPcId);
                int finalSubPcId = 0;
                if (subPcId == "REA015-PC") finalSubPcId = 1;
                else if (subPcId == "REA010-PC") finalSubPcId = 2;
                else if (subPcId == "DESKTOP-V4KPLUF") finalSubPcId = 3;
                else if (subPcId == "REA014-PC") finalSubPcId = 4;
                else if (subPcId == "REA005-PC") finalSubPcId = 5;
                else if (subPcId == "REA016-PC") finalSubPcId = 6;
                else if (subPcId == "SCOTT-PC") finalSubPcId = 7;
                else if (subPcId == "DESKTOP-Q6FFN6U") finalSubPcId = 8;
                else if (subPcId == "REA009-PC") finalSubPcId = 9;
                else if (subPcId == "ALI-PC") finalSubPcId = 10;
                else if (subPcId == "REA006-PC") finalSubPcId = 11;
                else if (subPcId == "DESKTOP-0B5GIC0") finalSubPcId = 12;
                else if (subPcId == "REA018-PC") finalSubPcId = 13;
                else if (subPcId == "EDREAINC-PC") finalSubPcId = 14;
                else if (subPcId == "REA013-PC") finalSubPcId = 15;
                else if (subPcId == "REA011-PC") finalSubPcId = 16;
                else if (subPcId == "JEA-PC") finalSubPcId = 17;
                else if (subPcId == "DESKTOP-UHJ55OH") finalSubPcId = 18;
                else if (subPcId == "REA019-PC") finalSubPcId = 19;
 
                //BACKUP_DATE COLUMN
                int startPosBackupDate = resultBackupText.IndexOf("Backup end: ") + "Backup end: ".Length;
                int lengthBackupDate = resultBackupText.IndexOf("Time taken: ") - startPosBackupDate;
                string subBackupDate = resultBackupText.Substring(startPosBackupDate, lengthBackupDate);
                string resultSubBackupDate = subBackupDate.TrimEnd('\n').TrimEnd('\r');
                DateTime finalResultSubBackupDate = DateTime.Parse(resultSubBackupDate);
 
                //BACKUP_JOB COLUMN
                int startPosBackupJob = resultBackupText.IndexOf("Iperius Backup Report") + "Iperius Backup Report".Length;
                int lengthBackupJob = resultBackupText.IndexOf("Backup start: ") - startPosBackupJob;
                string subBackupJob = resultBackupText.Substring(startPosBackupJob, lengthBackupJob);
                string resultSubBackupJob = subBackupJob.TrimStart('\r').TrimStart('\n').TrimEnd('\n').TrimEnd('\r');
 
                //BACKUP_RESULT COLUMN
                int startPosBackupResult = resultBackupText.IndexOf("Backup result: ") + "Backup result: ".Length;
                int lengthBackupResult = resultBackupText.LastIndexOf("Backup start: ") - startPosBackupResult;
                string subBackupResult = resultBackupText.Substring(startPosBackupResult, lengthBackupResult);
                string resultSubBackupResult = subBackupResult.TrimEnd('\n').TrimEnd('\r');
 
                //INSERT INTO BACKUP TABLE
                using (var context = new mayet_dashboardEntities1())
                {
                    var table = new backup
                    {
                        pc_id = finalSubPcId,
                        log_file = logItem,
                        backup_date = finalResultSubBackupDate,
                        backup_job = resultSubBackupJob,
                        backup_result = resultSubBackupResult,
                        backup_text = resultBackupText,
                        stamp_date = DateTime.Now
                    };
                    context.backups.Add(table);
                    context.SaveChanges();
                }
 
                //MOVE LOG FILE FROM LOGS TO LOGS_PROCESSED FOLDER
                string fileName = Path.GetFileNameWithoutExtension(logItem);
                string fileExtension = Path.GetExtension(logItem);
                Regex rgx = new Regex("[^a-zA-Z0-9 -]");
                string fileBackupDate = rgx.Replace(resultSubBackupDate, "");
                string fileRename = @"\\192.168.222.245\Backups\logs_processed\\" + fileName + "_" + subPcId + "_" + fileBackupDate + fileExtension;
                System.IO.File.Move(logItem, fileRename);
            }
        }
    }
}

 

pc.cs:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace MayetDashboard.Models
{
    using System;
    using System.Collections.Generic;
     
    public partial class pc
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public pc()
        {
            this.backups = new HashSet<backup>();
            this.events = new HashSet<@event>();
        }
     
        public int pc_id { get; set; }
        public string pc_name { get; set; }
        public Nullable<int> user_id { get; set; }
        public string system { get; set; }
        public string service_tag { get; set; }
        public Nullable<System.DateTime> purchase_date { get; set; }
        public string backup_code { get; set; }
        public string systeminfo_dump { get; set; }
     
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<backup> backups { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<@event> events { get; set; }
        public virtual user user { get; set; }
    }
}

 

backup.cs:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
 
namespace MayetDashboard.Models
{
    using System;
    using System.Collections.Generic;
     
    public partial class pc
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
        public pc()
        {
            this.backups = new HashSet<backup>();
            this.events = new HashSet<@event>();
        }
     
        public int pc_id { get; set; }
        public string pc_name { get; set; }
        public Nullable<int> user_id { get; set; }
        public string system { get; set; }
        public string service_tag { get; set; }
        public Nullable<System.DateTime> purchase_date { get; set; }
        public string backup_code { get; set; }
        public string systeminfo_dump { get; set; }
     
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<backup> backups { get; set; }
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public virtual ICollection<@event> events { get; set; }
        public virtual user user { get; set; }
    }
}

 

Thank you!

Konstantin Dikov
Telerik team
 answered on 13 Nov 2018
1 answer
805 views

Hi support team

Our customer wants to display the content of a simple (i.e. one sheet, simple content, see sample image attached) excel on a ASP.NET MVC rendered page. Is there a way to configure the Spreadsheet component without any menues and additional functionality like editing, copy/paste, etc.? 

Or is there a smarter way to provide such "viewer-only" functionality, like loading the excel sheet and display its contet in a Grid component? 

Uploading the file is not an issue, we have implemented this already. My question is only about rendering/displaying the content of a excel sheet on a page.

Any advice is highly appreciated. 

Regards, Daniel 

Marin Bratanov
Telerik team
 answered on 12 Nov 2018
3 answers
688 views

Hello,

I created a new C# MVC Application using the template provided by Telerik. for some reason the controls do not render when running the application. I checked the references in the layout page and the web.config files and everything looks correct. I am using  vs 2017 and am on 4.6.1 Framework

I have attached a screen shot of how the dropdownlist is rendered(copied code from website)

 

Thanks,

M. Blake

 

Marin Bratanov
Telerik team
 answered on 12 Nov 2018
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
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
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?