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

I am using Kendo Tree View.
I construct a HierarchicalDataSource, but I get a 'stack overflow' error when I try to call SetDataSource to bind the data.
I get this error in IE 8.0.7601.17514CO 64bit, and no error in chrome.

here is my code:

public class TDNode
    {
        public string id { get; set; }
        public string text { get; set; }
        public string ctrlTypeCssClass { get; set; }
        public bool expanded { get; set; }
        public bool hasChildren { get; set; }
        public string parentid { get; set; }
        public List<TDNode> items = new List<TDNode>();
    }

 success: function (data) {
                var newDataSource = null;
                newDataSource = new kendo.data.HierarchicalDataSource({
                    data: data
                });

                $("#tvtemplate").data("kendoTreeView").setDataSource(newDataSource);
            }

Thanks.


Alex Gyoshev
Telerik team
 answered on 31 Oct 2014
3 answers
111 views
In our JS onClick event we have the following code:

        var grid = $("#MyGrid").data("kendoGrid");
        var row = grid.select();

When running on IE (test on versions 9, 10, 11) the row is null if the row isn't specifically selected before clicking on the button. Any work around for this?

thanks

Bill
Dimiter Madjarov
Telerik team
 answered on 31 Oct 2014
1 answer
172 views
I need to know how to properly build a gridtemplatecolumn in code behind.

@(Html.Kendo().Grid<DealViewModel>().Name("Grid").AutoBind(false).Scrollable(x => x.Height("auto")).Columns(columns =>
                                                                                                              columns.AutoGenerate(a =>
                                                                                                              {
                                                                                                                  a.Encoded = false;
                                                                                                              })).Columns((columns) => Utilities.SetColumnProperties(columns.Container.Columns, @ViewBag.CurrentStepId)).Sortable(x=>x.SortMode(GridSortMode.SingleColumn))

the second columns call the SetColumnProperties method where I query the database to get the columns properties that are set by the user as follows.

/////////////
/////////////
/////////////


public static void SetColumnProperties(IList<GridColumnBase<DealViewModel>> columns, Guid currentStepId)
{
var column = ContextHelper.Context.SalesStep.Find(currentStepId).Column.ToList();
var columnsToAdd = new List<GridColumnBase<DealViewModel>>();

columns.ForEach(x =>
{
var currentColumn = column.FirstOrDefault(y => y.ColumnName.Name.Equals(x.Member, StringComparison.InvariantCultureIgnoreCase));

x.Visible = currentColumn != null;
var gridBoundColumn = x as IGridBoundColumn;
if (gridBoundColumn == null || currentColumn == null)
{
return;
}
//TASKS ENABLED
if (x.Member.Equals("TaskTo"))
{
x.Visible = TaskingUtilities.TaskingEnabled;
}

if (new List<string>
{
"TaskTo",
"TakeOwnership",
"ReturnButton",
"RejectTask",
"CompleteTask",
"Approve",
"ApproveTo",
"Deny",
"DenyTo"
}.Contains(x.Member))
{
var claims = ClaimsPrincipal.Current.Claims;
var firstOrDefault = claims.FirstOrDefault(y => y.ValueType.Equals(currentStepId.ToString()));
if (firstOrDefault != null)
{
var enumString = firstOrDefault.Value;
SedonaSalesWorkflow.StepAccessLevel returnVal;
var stepAccessLevel = Enum.TryParse(enumString, true, out returnVal) ? returnVal : SedonaSalesWorkflow.StepAccessLevel.None;

x.Visible = stepAccessLevel == SedonaSalesWorkflow.StepAccessLevel.Full;
}
else
{
x.Visible = false;
}
}




if (currentColumn.Width != 0)
{

x.Width = currentColumn.Width.ToString(CultureInfo.InvariantCulture) + "px";
}
gridBoundColumn.Hidden = currentColumn.IsHidden;
gridBoundColumn.Title = currentColumn.Title;
gridBoundColumn.Format = currentColumn.Format;
gridBoundColumn.Filterable = currentColumn.Filterable;
gridBoundColumn.Sortable = currentColumn.Sortable;
gridBoundColumn.Groupable = currentColumn.Groupable;                
});
}//////////////////////////

/////////////

/////////////
Now how do I add a GridTemplateColumn correctly.  I can get it to show but I want to build a column dynamically from code behind.  There is basically one grid that users can add/remove fields to and create a new page and then set properties on that field which is why this is done this way.  I would like to basically concatenate columns of a certain type.

This currently does not work
columns.FirstOrDefault().Grid.Columns.Add(new GridTemplateColumn<DealViewModel>(columns.FirstOrDefault().Grid, model => model.Approve)
            {
                ClientTemplate = "#= Approve #"
            });

Thanks for the help.
































Petur Subev
Telerik team
 answered on 31 Oct 2014
1 answer
717 views
Hi, 

I'm using the numeric text box as follows: 

<div class="col-md-7 col-sm-6">
    @(Html.Kendo().NumericTextBoxFor(m => m.MaintenanceYearlyAmount).Decimals(1).Deferred(true))
    @Html.ValidationMessageFor(m => m.MaintenanceYearlyAmount)
</div>

The model property 'MaintenanceYearlyAmount' has the following attributes for validation: 
[Display(Name = "Annual Maintenance")]
[Required]
[Range(0,1000)]
[ToolTip("Dependant's Annual Maintenance")]
public decimal? MaintenanceYearlyAmount
{
    get
    {
        return ModelEntity.MaintenanceYearlyAmount;
    }
    set
    {
        ModelEntity.MaintenanceYearlyAmount = value;
    }
}

When testing this I get the following results: 
  • I enter 999.56 - It rounds up to 999.60 (Why is it showing the additional zero at the end when I've specified only 1 decimal?)
  • I enter 1111 and tab off the control - I get a valid validation message of 'Please enter a value less than or equal to 1000' AND it automatically changes the value to 1000 (is there a way to stop this from happening? The user should be warned, but it's there responsibility to change the value not to have it automatically changed. They might have entered 9845 accidentally adding the 5 at the end and instead of just deleting the 5 they have to type the number out again. 
  • I remove the Range validation and keep only the Required validation.  
    • I delete the current value for MaintenanceYearlyAmount and for Full Name (which is a normal Microsoft textbox and is required in the model) and click save. - Full name correctly shows its validation message, but the Kendo numeric textbox doesn't. This is where the problem is. I'm not sure why the client side validation doesn't fire correctly or show the validation message. If I add the Full name value back and click submit/save again, Full name passes, the form submits and server side validation fails sending the form back with the correct message under the MaintenanceYearlyAmount input. So bottom line is that the validation works server side, but not client side for the Required Validator. 
Georgi Krustev
Telerik team
 answered on 30 Oct 2014
1 answer
332 views
I have tried to follow the Kendo example (http://demos.telerik.com/aspnet-mvc/grid/filter-menu-customization) but I am clearly missing something...

The grid loads data just fine. The javascript function `costCenterNumberFilter(element);` is executed as I have placed an `alert("blah");` and that is displayed in the browser...

It will not render the AutoComplete for cost center number filter. Any help will be greatly appreciated.


Index.cshtml:

@model IEnumerable<LoanFee>
 
@{
    ViewBag.Title = "Fees";
}
 
@(Html.Kendo().Grid<LoanFee>(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Command(cmd => cmd.Select())
            .HtmlAttributes(new { style = "text-align: center;" })
            .Width(100);
        columns.Bound(p => p.AccountNumber)
            .Width(170);
        columns.Bound(p => p.CustomerName);
        columns.Bound(p => p.StatusId)
            .Template(@<text></text>)
            .HtmlAttributes(new { @class = "status-dropdown" })
            .ClientTemplate(Html.Kendo().DropDownList()
                .Name("ddlStatus_#=LoanFeeId#")
                .DataTextField("Name")
                .DataValueField("Value")
                .BindTo(Status.Items())
                .Value("#=StatusId#")
                .ToClientTemplate()
                .ToHtmlString())
            .Title("Status")
            .Width(100);
        columns.Bound(p => p.Approvals)
            .HtmlAttributes(new { style = "text-align: center;" })
            .Width(100);
        columns.Bound(p => p.Amount)
            .Format(Formats.CURRENCY)
            .HtmlAttributes(new { style = "text-align: right;" })
            .Width(120);
        columns.Bound(p => p.Allocation.PrimaryOfficerName)
            .Template(@<text></text>)
                .ClientTemplate("#=Allocation.PrimaryOfficerNumberDashName#")
            .Width(220);
        columns.Bound(p => p.CostCenterNumber)
            .Title("Cost Center")
            .HtmlAttributes(new { style = "text-align: center;" })
            .Filterable(filterable =>
            {
                filterable.Extra(false);
                filterable.Operators(o => o.ForString(fs =>
                {
                    fs.Clear();
                    fs.Equals("Equals");
                }));
                filterable.UI("costCenterNumberFilter");
            })
            .Width(100);
        columns.Bound(p => p.DateEntered)
            .Format(Formats.DATE)
            .HtmlAttributes(new { style = "text-align: center;" })
            .Width(100);
 
    })
    .Events(e => e.DataBound("initStatusDropdown"))
    .Pageable()
    .Filterable()
    .DataSource(ds => ds
        .Ajax()
        .PageSize(15)
        .Sort(sort => sort.Add(p => p.AccountNumber))
        .Model(m =>
        {
            m.Id(p => p.LoanFeeId);
        })
        .Read(read => read.Action("Index_Read", "WorkQueue"))
    )
)
 
<script type="text/javascript">
 
    function initStatusDropdown(e) {
 
        $(".status-dropdown").each(function () {
 
            eval($(this).children("script")
                .last()
                .html());
        })
    }
 
    function costCenterNumberFilter(element) {
 
        element.kendoAutoComplete({
            datasource: ["3200", "4200", "1000"]
        });
    }
 
</script>


WorkQueueController.cs:

using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace CommercialIncentive.Web.Areas.Fees.Controllers
{
    public class WorkQueueController : BaseController
    {
        public ActionResult Index()
        {
            return View();
        }
 
        public ActionResult Index_Read([DataSourceRequest] DataSourceRequest request)
        {
            var data = IocContainer.Get<ILoanFeeService>()
                    .ListAsQuery()    // Returns IQuerable<LoanFee>
                    .ToDataSourceResult(request);
 
            return Json(data);
        }
    }
}


John
Top achievements
Rank 2
 answered on 30 Oct 2014
1 answer
140 views
Is there a spell checker for MVC?
If not will there be one soon?
Thanks
Robert
Kiril Nikolov
Telerik team
 answered on 30 Oct 2014
3 answers
162 views
Hi.  I would like to know if there is any way to delay a clicked tab from displaying until my corresponding MVC controller action is completed?  The following code below calls an MVC controller "Controller" with the ActionResult "ControllerAction" and "message" is the name of the tab I am displaying for validation.
Currently, I have a function called within the if statement if(a_tabPageSelected == "MyTab") which takes a while to complete and would prefer if the tab section didn't appear until the function completes.

Controller.cs
public ActionResult ControllerAction(string a_tabPageSelected)
{
   if(a_tabPageSelected == "MyTab")
   {
        /// do stuff before tab page appears
   }
 
/// now display tab page using some command and return View
return View("Tabsection");




View.cshtml
 
function onSelect(e) {
   var message = $(e.item).find("> .k-link").text();
   $.get('/Controller/ControllerAction/?a_tabPageSelected=' + message, function (data) {
   $("#TabDiv").html(data);
   });
}
Kiril Nikolov
Telerik team
 answered on 30 Oct 2014
3 answers
192 views
i have a Kendo grid that uses an edit Popup. The culture in the client is de-DE, when an user tries to edit a decimal number i.e. 8,5 Kendo sends a null to the server for that value and returns validation message "The value 8.5 is not valid for 'PropertyName'". Any help will be greatly appreciated.

@{
var culture = System.Globalization.CultureInfo.CurrentCulture.ToString();
}

<script src="@Url.Content("~/Scripts/Kendo/cultures/kendo.culture." + culture + ".min.js")"></script>

<script type="text/javascript">
kendo.culture("@culture");
</script>

jQuery.extend(jQuery.validator.methods, {
date: function (value, element) {
return this.optional(element) || kendo.parseDate(value) != null;
},
number: function (value, element) {
return this.optional(element) || kendo.parseFloat(value) != null;
}
});
@(Html.Kendo().Grid<SalesToolkit.ViewModels.AdminEquipDimViewModel.Equipment>()
.Name("grdEquipDim")
.Columns(columns =>
{
columns.Bound(dim => dim.EquipmentID).Width(50).Title("ID").Hidden(true);
columns.Bound(dim => dim.EquipmentName).Width(140).Title("Equipment Name");
columns.ForeignKey(dim => dim.EquipmentTypeID, (System.Collections.IEnumerable)ViewData["EquipTypes"], "EquipmentTypeID", "EquipmentName").Width(60).Title("Type");

columns.Bound(dim => dim.Metric).Width(55);
columns.Bound(dim => dim.ModelVerified).Width(65);
columns.Bound(dim => dim.LastModifiedBy).Width(130);
columns.Bound(dim => dim.TimeStamp).Format("{0:MM/dd/yyyy hh:mm:ss}").Width(120);

columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Scrollable()
.HtmlAttributes(new { @class = "dimGrid" })
.Sortable()
.Pageable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Field(dim => dim.EquipmentID).Editable(false);
model.Field(dim => dim.TimeStamp).Editable(false);
model.Field(dim => dim.LastModifiedBy).Editable(false);
})
.Events(events => events.Error("error"))
.Model(model => model.Id(dim => dim.EquipmentID))
.Create(update => update.Action("EquipDim_Create", "AdminEquipDim", new { mID = Model.ManufacturerID }))
.Read(read => read.Action("EquipDim_Read", "AdminEquipDim", new { mID = Model.ManufacturerID }))
.Update(update => update.Action("EquipDim_Update", "AdminEquipDim"))
.Destroy(update => update.Action("EquipDim_Delete", "AdminEquipDim"))
)
)

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EquipDim_Update([DataSourceRequest] DataSourceRequest request, AdminEquipDimViewModel.Equipment equipMfg)
{
if (equipMfg != null && ModelState.IsValid)
{
AdminEquipDim oEquipMfg = new AdminEquipDim();
oEquipMfg.UpdateEquipDim(equipMfg);
}

return Json(ModelState.ToDataSourceResult());
}



Petur Subev
Telerik team
 answered on 29 Oct 2014
1 answer
95 views
I was told that this new release will contain a new Export to Excel Widget from the MVC Grid.

Is that true?
If so where can I find documentation about it.
Thanks
Robert
Kiril Nikolov
Telerik team
 answered on 29 Oct 2014
3 answers
174 views
I haven't been able to figure out how to set the series with a data source returned from a controller (see below). What do I need to pass to series.Line()?

The controller method returns a list of long integers.

        @(Html.Kendo().Chart()
            .Name("jobHistoryChart")
            .Title("Batch Job History")
            .Theme("Bootstrap")
            .Legend(legend => legend.Visible(true).Position(ChartLegendPosition.Bottom))
            .HtmlAttributes(new
            {
                style = "margin-top:15px; border:thin solid steelblue; padding:10px; padding-bottom:20px;"
            })
            .DataSource(dataSource => dataSource.Read(read => read.Action("GetBatchJobHistory", "Home",
                new { histJobCaption = "Load Inventory Usage Summary Data" })))
            //.Series(series =>
            //{
            //    series.Line().Name("Batch Job");
            //})

        )

Hristo Germanov
Telerik team
 answered on 28 Oct 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
Upload
ComboBox
MultiSelect
Window
ListView
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
Licensing
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
AICodingAssistant
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
+? 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?