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

Hi, I'm using a ListBox with a template.

<script id="roleChoiceTemplate" type="text/x-kendo-template">
<div class="row"><div class="col-sm-9"> #: data.RoleName #</div> <div class="col-sm-3">#: data.RoleNeedsAttention == true ? 'Y' : ''#</div></div>
</script>
 
@(Html.Kendo().ListBox()
                       .Name("roleChoices")
                       .DataTextField("RoleName")
                       .DataValueField("RoleName")
                       .TemplateId("roleChoiceTemplate")
                       .HtmlAttributes(new { style = "width: 100%; overflow: hidden;" })
                           .DataSource(source => source
                               .Read(read => read.Action("GetRoles", "Home"))
                           )
 
       )

As is, this works fine, but instead of displaying a 'Y' in the template when the value is true, I want to display a formatted span like <span class=\'needsAttention\'>Attention</span>.  When I try to do this, I either see the text '<span>...' or with different alterations I get an invalid template javascript error.  Can you help me get the syntax right because I'm out of ideas.

 

Thanks!

Georgi
Telerik team
 answered on 22 Aug 2018
6 answers
245 views

Hello,

I try to load child nodes on parent's expansion with the data remote binding.
But when i do like the exemple (https://demos.telerik.com/aspnet-mvc/treelist/remote-data-binding) My first level is correctly loaded but I can't expand them beacause there is no icon to do it on my treelist. See Screenshot there

I got the same issue on your sample application. I runned your solution and there is no icon to expand parent also. See screenshot

My current kendo version is 2017.2.504.545.

Also, I found on the forum another user who has the same problem (https://www.telerik.com/forums/mvc-treelist-load-on-demand, see the end of the topic)

There is my treelist view 

@(Html.Kendo().TreeList(Model)
            .Name("hierarchyTreelist")
            .Toolbar(x => {
                if (ViewBag.Mode == TypeArbo.MP.ToString())
                {
                    x.Create().Text(" ");
                }
            })
            .Editable(editable => editable.Mode("popup").TemplateName("HierarchyPopUpEditor"))
            .Sortable()
            .Filterable(ftb => ftb.Extra(false))
            .Resizable(true)
            .Scrollable(true)
            .ColumnMenu()
            .Columns(columns =>
            {
                columns.Add().Field(e => e.Id).Hidden(true);
                columns.Add().Field(e => e.Libelle);
                columns.Add().Field(e => e.Code).Width(140);
                columns.Add().Field(e => e.CodeParent).Width(140);
                columns.Add().Field(e => e.CodeEtLibelleUbaldi).Width(200).Hidden(ViewBag.Mode == TypeArbo.Ubaldi.ToString());
                columns.Add().Field(e => e.FamilleLogistiqueNom).Width(250).Hidden(ViewBag.Mode == TypeArbo.Ubaldi.ToString());
                columns.Add().Field(e => e.IsActif).Template("#= IsActif ? 'Oui' : 'Non' #").Width(100);
                columns.Add().Title("Attributs").Command(c =>
                {
                    c.Custom().Click("AttributView").Text(" ").Name("btnEditHierarchyAttribut").ImageClass("glyphicon glyphicon-th-list").ClassName("btn btn-info");
                }).Width(80);
                if (ViewBag.Mode == TypeArbo.MP.ToString())
                {
                    columns.Add().Command(c =>
                    {
                        c.CreateChild().Text(" ").ClassName("btn btn-success");
                        c.Edit().Text(" ").ClassName("btn btn-primary");
                        c.Custom().Click("MoveView").Text(" ").Name("btnMoveHierarchy").ImageClass("glyphicon glyphicon-move").ClassName("btn btn-warning");
                        c.Custom().Click("DeleteView").Text(" ").Name("btnDeleteHierarchy").ImageClass("k-i-trash").ClassName("btn btn-danger");
                    }).Width(250);
                }
            })
            .DataSource(dataSource => dataSource
                .Create(create => create.Action("Create", "Hierarchie"))
                .Update(update => update.Action("Update", "Hierarchie"))
                .Destroy(destroy => destroy.Action("Delete", "Hierarchie"))
                .Read(read => read.Action("GetHierarchies", "Hierarchie",
                                  new { typeArbo = ViewBag.Mode, txtCode = Code, txtLibelle = Libelle, txtParent = CodeParent, txtFamLogi = FamLogi, rdblIsActif = IsActif }))
                .Model(m =>
                {
                    m.Id(f => f.Code);
                    m.ParentId(f => f.CodeParent);
                    m.Field(f => f.Libelle);
                    m.Field(f => f.IsActif);
                    m.Field(f => f.Description);
                    m.Field(f => f.URL);
                    m.Expanded(false);
                })
            )
            .Events(e =>
            {
 
                e.Edit("OnEdit");
                e.Save("OnSave");
            })
)

 

And there my data controller action :

        public JsonResult GetHierarchies([DataSourceRequest] DataSourceRequest request,string id, TypeArbo typeArbo, string txtCode, string txtLibelle, string txtParent, string txtFamLogi, bool? rdblIsActif)
        {
 
            List<PIMHierarchy> list = new List<PIMHierarchy>();
 
            if (rdblIsActif != null)
                list = hierarchyManager.GetByParams(txtCode, txtLibelle, txtParent, txtFamLogi, typeArbo)
                                  .Where(h => ((bool)rdblIsActif && h.IsActif || !(bool)rdblIsActif && !h.IsActif)).ToList();
            else
                list = hierarchyManager.GetByParams(txtCode, txtLibelle, txtParent, txtFamLogi, typeArbo).ToList();
 
            TreeDataSourceResult result = result = list.ToTreeDataSourceResult(request,
                                                    e => e.Code,
                                                    e => e.CodeParent,
                                                    e => id != null ? e.CodeParent == id : e.CodeParent == string.Empty,
                                                    e => e
                                                );
 
            return Json(result, JsonRequestBehavior.AllowGet);
}

 

Do you have any ideas where the problem is ? 

Thank you for you time on that issue,

 

Stefan
Telerik team
 answered on 22 Aug 2018
2 answers
139 views

Hello,

we´ve just bought DevCraft and to get into the stuff, I´ve programmed a little application. But I have a problem with the Grid. Using the Model-Function in the DataSource I get a "Overload resolution failed"-Exception, but I don´t see why. When I remove the "Model"-Part in the Datasource the exception disappears

@Html.Kendo.Grid(Model.Pruefdienste).Name("grdAdress") _
                                    .ToolBar(Sub(t)
                                      t.Create()
                                      t.Save()
                                    End Sub) _
.Editable(Sub(e)
                                      e.DisplayDeleteConfirmation(True)
                                      e.Mode(GridEditMode.PopUp)
                                    End Sub) _
.Columns(Sub(cols)
                                      cols.Select()
                                      cols.Bound(Function(c) c.IDAdress).Hidden()
                                      cols.Bound(Function(c) c.Name)
                                      cols.Bound(Function(c) c.Street)
                                      cols.Bound(Function(c) c.ZIP)
                                      cols.Bound(Function(c) c.City)
                                      cols.Bound(Function(c) c.Email)
                                      cols.Bound(Function(c) c.www)
                                      cols.Bound(Function(c) c.Phone)
                                    End Sub) _
    .Pageable(Sub(p)
                                       p.PageSizes(True).PageSizes(New Integer() {20, 50, 100})
                                    End Sub) _
.Sortable.Filterable.Groupable.Scrollable(Sub(s) s.Height("auto")) _
.DataSource(Sub(ds)
                                      ds.Ajax().Model(Sub(model) model.Id("IDAdress")).Read(Sub(read) read.Action("GetAdresses", "Adress").Data("filterGrid"))
                                     End Sub)

I have also tried  

ds.Ajax().Model(Function(model) model.Id(Function(mo) mo.IDAdress)).Read(Func...

but without success.

Thank you very much for your help.

Martin
Top achievements
Rank 1
 answered on 22 Aug 2018
1 answer
319 views

In my grid, when I click an inline edit it is showing the default browser edit inputs instead of styling it per kendo UI. I've attached a screenshot showing this issue. I'm expecting the first two fields to be text inputs which take the full width and the third input to be a date/time picker (its underlying data type is a Nullable<DateTime>). Validation appears to work properly despite this.

The code to generate the grid is as follows:

@(Html.Kendo().Grid<UserModel>()
        .Name("UserList")
        .HtmlAttributes(new { style = "height: 550px" })
        .DataSource(o => o.Ajax()
            .Model(m => m.Id<string>(u => u.Id))
            .Read(r => r.Action("_UserList_Read", "Admin"))
            .Update(u => u.Action("_UserList_Update", "Admin"))
            .Destroy(d => d.Action("_UserList_Delete", "Admin"))
            )
        .Columns(c =>
        {
            c.Bound(o => o.DisplayName);
            c.Bound(o => o.Email);
            c.Bound(o => o.LockoutEndDateUtc);
            c.Command(o => { o.Edit(); o.Destroy(); }).Width(230);
        })
        .Pageable(p => p.PageSizes(new int[] { 10, 20, 50, 100 }))
        .Sortable()
        .Filterable()
        .Scrollable()
        .Editable(o => o.Mode(GridEditMode.InLine))
)

 

Using latest version of Kendo UI (2018.2.620 with bootstrap 4 theme). jQuery 3.3.1 and bootstrap 4.1.3.

Any advice on how to get these to apply styles (and the correct editors)?

Georgi
Telerik team
 answered on 21 Aug 2018
2 answers
1.8K+ views

We've got a drop down list inside a pop-up template from a grid. This drop down list is being populated correctly and you can select a value from the list and the value will be sent to the controller correctly. However when the data is loaded no value is selected initially so we are calling the select(0) function to automatically select the first item in the list. But when we do this the id value is not passed to the controller if the user doesn't select another item from the list.

Below is the DropDownList control. We are using the DataBound event to set the default value.

@(Html.Kendo().DropDownList()
                  .Name("ParentId")
                  .DataSource(ds => ds
                      .Custom()
                      .Transport(tr => tr
                          .Read(read => read.Action("OHGetGroupsForDropDown", "Groups")))
                      .Schema(sc => sc.Data("Data").Total("Total").Errors("errors")))
                  .DataValueField("Id")
                  .DataTextField("Name")
                  .Filter(FilterType.Contains)
                  .Events(e => e.DataBound("parentIdDefaults"))
                  .HtmlAttributes(new {@style = "width:100%", data_value_primitive = "true"}))

 

Below is the DataBound() event code. We are simply selecting the first item in the list.

function parentIdDefaults(e) {
        var dropdownlist = $("#ParentId").data("kendoDropDownList");
        dropdownlist.select(0);
    }

 

The above code works visually but if we do not select another item in the drop down list the ParentId value of the object passed to the controller is 0. If we select another item in the list the ParentId value passed to the controller is correct. 

Does anyone know why the select() call is not fully selecting the drop down list item but only appears to?

Dimitar
Telerik team
 answered on 21 Aug 2018
1 answer
7.7K+ views
I cannot seem to find out how to do this from the documentation.

My model has a Boolean field which displays as 'true' or 'false'.

How can I set the grid to display as 'Yes' or 'No' respectively.

Thanks,

Richard
Konstantin Dikov
Telerik team
 answered on 21 Aug 2018
12 answers
156 views

Hi Team,

            I am new to Kendo MVC and have a requirement. I want to achieve the below diagram is it possible ?

I am getting the shapes.

Please note the connector positions. They are not overlapping. every connector is different direction so that it looks good.

Please help.

Attached is the diagram I want to get.

Sanjukta
Top achievements
Rank 1
 answered on 20 Aug 2018
1 answer
359 views

Hi I have a grid that requires two different tooltips (1 for column a and 1 for column b) yet when I hover over either column, I see both tooltips overlaying each other.  Is there something I'm doing wrong, or can you tell me a strategy to fix this?

 

Sorry for the strange formatting.  My grids are embedded inside a Telerik TabStrip, and that just sends the Visual Studio Editor crazy!!  (Do you happen to have a solution for that also?  It's extremely hard to read)

 

@(Html.Kendo().Grid<DemandVM>()
                                                .Name("initialGrid")
                                                .Columns(columns =>
                                                {
                                                        columns.Bound(c => c.Title).ClientTemplate(" <a href='" + Url.Action("DemandDetail", "Demand") + "/#= RequirementId #'" + ">#= changeNewLine(data.Title)#</a>");
                                                        columns.Bound(c => c.SkillsDisplayName).ClientTemplate("<div class=\"forTooltips\">#=SkillsDisplayName#</div>").HtmlAttributes(new { @class = "overridePadding" });
                                                        columns.Bound(c => c.WorksiteLocationsDisplayName).ClientTemplate("<div class=\"forTooltips\">#=WorksiteLocationsDisplayName#</div>").HtmlAttributes(new { @class = "overridePadding" });
                                                                                                        })
                                                .Events(e =>
                                                {
                                                        e.Change("GridRowSelected");
                                                    })
                                                .ToolBar(toolbar =>
                                                {
                                                        toolbar.Excel();
                                                        toolbar.Pdf();
                                                    })
                                                .ColumnMenu()
                                                .Pageable()
                                                .Navigatable()
                                                .Selectable()
                                                .Sortable(sortable =>
                                                {
                                                        sortable.SortMode(GridSortMode.SingleColumn);
                                                    })
                                                .Filterable(filterable => filterable.Mode(GridFilterMode.Menu))
                                                .Scrollable(s => s.Height("auto"))
                                                .DataSource(dataSource => dataSource
                                                .Ajax()
                                                .ServerOperation(false)
                                                .Read(read => read.Action("Search", "Demand").Data("filterList"))
 
                                )
                                .NoRecords("No Demands Found")
                                )
                                @(Html.Kendo().Tooltip()
                                    .For("#initialGrid")
                                    .Filter(".forTooltips")
                                    .ContentHandler("getSkillsToolTipInitial")
                                    .Position(TooltipPosition.Right)
                                    .AutoHide(true)
 
                                )
 
                                @(Html.Kendo().Tooltip()
                                .For("#initialGrid")
                                .Filter(".forTooltips")
                                .ContentHandler("getWorksiteLocationsToolTipInitial")
                                .Position(TooltipPosition.Right)
                                .AutoHide(true)
 
                                )

 

 

Michael
Top achievements
Rank 1
 answered on 17 Aug 2018
2 answers
1.5K+ views

I've been searching and and I cannot find a thread or answer for what I'm doing specifically. I have a site where a user will be creating a record called 'ManualProcess'. In the pop-up they will enter general information about the record and then with the Upload() select files to be uploaded and associated to this main record. The files will be stored in a separate table name 'ManualPrcoessDeocuments' with a FK relationship back to the 'ManualProcess' record.

 

What I'm trying to do is have the HttpPostedFileBase[] object be passed back to the controller along with the 'ManualProcess' record. I have been able to get it to call and pass a value using the async option but that occurs before they have sent the main record data. So ido not have the main record id to associate the documents with. 

Below is the grid code.

@(Html.Kendo().Grid(Model).Name("ManualWorkflowProcess").Columns(c =>
      {
          c.Bound(e => e.Name);
          c.Bound(e => e.Description);
          c.Bound(e => e.ApprovalProcessName);
          c.Bound(e => e.Active).ClientTemplate("<input type='checkbox' disabled='disabled' value='#= Active #' " + "# if (Active) { #" + "checked='Active'" + "# } #" + "/>").Width(100);
          c.Command(command =>
          {
              command.Edit();
              command.Destroy();
          }).Width(200);
      })
          .ToolBar(toolbar => toolbar.Create().Text("Create New Process"))
          .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ManualProcessPopUp").Window(w => w.Width(700)))
          .Pageable(pager => pager.AlwaysVisible(false).PageSizes(new List<object> { 5, 10, 20, 100 }))
          .Sortable()
          .Filterable()
          .Groupable()
          .Events(events => events.Edit("Edit"))
          .DataSource(dataSource => dataSource
                  .Ajax()
                  .PageSize(20)
                  .Model(model => model.Id(p => p.Id))
                  .Create(update => update.Action("EditingPopup_Create", "ManualApprovalProcesses"))
                  .Read(read => read.Action("EditingPopup_Read", "ManualApprovalProcesses"))
                  .Update(update => update.Action("EditingPopup_Update", "ManualApprovalProcesses"))
              .Destroy(update => update.Action("EditingPopup_Destroy", "ManualApprovalProcesses"))
        ))

 

Below is the Upload() code in the pop-up template

<div class="editor-label">
    @Html.Label("Files", htmlAttributes: new { @class = "control-label col-md-10" })
</div>
<div class="editor-field">
    @(Html.Kendo().Upload().Name("FileUploads").HtmlAttributes(new { aria_label = "files" })))
</div>

Below is my controller code.

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ManualApprovalProcess manualProcess, HttpPostedFileBase[] fileUploads)
        {
            if (manualProcess != null && ModelState.IsValid)
            {
                this.Update(manualProcess);
            }
 
            return Json(new[] { manualProcess }.ToDataSourceResult(request, ModelState));
        }

 

So I want to have the file data passed back to the controller so I can create the main record and then use that id and loop over the documents and use that new id when creating the document records.

If this possible the way I'm trying to achieve this? I can;t do the async call because I will be missing come data that I need to properly upload and create the document records as well as upload them to the correct location in Azure.

 

 

 

Phillip
Top achievements
Rank 1
 answered on 17 Aug 2018
2 answers
938 views

Hi,

I declared the below Kendo grid with checkbox column. Below is the javascript script

@model IEnumerable<NotificationTypesModel>

<script type="text/javascript">


    function CloseNotificationPopup() {
        $('#ManageNotifications').data('kendoWindow').close();        
    }
   
    function OnNotificationsBound(e) {
        e.preventDefault();
        var grid = this;
        var rows = grid.items();

        $(rows).each(function (e) {
            var row = this;
            var dataItem = grid.dataItem(row);
            if (dataItem.IsRowSelected == true) {
                grid.select(row);
                //dataItem.IsRowSelected = false;
            }
        });
    }
    
    function SaveNotificationPreferences() {
        var items = [];
        
        var notificationTypesGrid = $('#NotificationTypes').data("kendoGrid");

        for (var i = 0; i < notificationTypesGrid.selectedKeyNames().length ; i++) {
            var currentDataItem = notificationTypesGrid.selectedKeyNames()[i];
            items.push(currentDataItem);            
        }
    }
</script>

The below is the kendo grid

@(Html.Kendo().Grid(Model)
    .Name("NotificationTypes")
    .Columns(columns =>
    {
        columns.Select().Width(39).HeaderHtmlAttributes(new { style = "text-align:center" }).HtmlAttributes(new { style = "text-align:center", tabindex = "1" });
        columns.Bound(p => p.NotificationTypeID).Visible(false);
        columns.Bound(p => p.IsRowSelected).Visible(false);
        columns.Bound(p => p.NotificationTypeName);
    })
    .Pageable(page =>
    {
        page.PageSizes(true);
        page.PreviousNext(true);
        page.Input(true);
        page.PageSizes(new int[] { 5, 10, 20, 50, 100 });
    })
    .Sortable()
    .PersistSelection()
    .Events(e => e.DataBound("OnNotificationsBound"))    
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(false)
        .PageSize(5)
        .Model(model => model.Id(p => p.NotificationTypeID))
        .ServerOperation(false)
    )
)

 

Below is the class I am using to bind

public class NotificationTypesModel
    {
        public Guid NotificationTypeID { get; set; }
        public string NotificationTypeCode { get; set; }
        public string NotificationTypeName { get; set; }
        public bool IsRowSelected { get; set; }
    }

 

When the page loads I am selecting the rows based on the data retrieved from the database. This is done inside the OnNotificationsBound event.

And on the page there is a button which will save the selections back to the database. The issue I am having is in the SaveNotificationPreferences() method I am not getting the records of selections from all the pages.  I am unable to figure out the issue.

I am using the below version of Kendo.

2017.3.1018.545

Sriram
Top achievements
Rank 1
 answered on 16 Aug 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
Bronze
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
Bronze
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?