Telerik Forums
Kendo UI for jQuery Forum
7 answers
2.8K+ views
Hi, I have a Kendo Grid with column templates to handle date formatting, null values, etc., and the columns are set to sortable.  However, when I click a column header to sort the sort arrow changes but the data does not sort. Below is the grid definition.  Any ideas would be very much appreciated!

var gridDataSource = new kendo.data.DataSource({
    data: results,
    total: results.length,
    pageSize: 20,
    schema: {
        model: {
            id: "id",
            fields: {
                attributes: { type: "object" }
            }
        }
    }
});
 
//Build the Kendo UI grid
var kendoDataGrid = $("#dataGrid").kendoGrid({
    dataSource: gridDataSource,
    columns: GetGridColumns(),
    scrollable: true,
    pageable: true,
    resizable: true,
    sortable: true,
    selectable: "row",
    navigatable: true,
    height: gridHeight,
    editable: false
}).data("kendoGrid");
Alex Hajigeorgieva
Telerik team
 answered on 28 Jun 2019
2 answers
263 views

Couldn't find any similar questions on the forum so hopefully someone can help :)

 

At the moment I have a pre-filter on my grid, which filters a column based on the role of the logged in user.

 

filter: {

           filters: [{ field: "RSM", operator: "contains", value: manager}]
         }

 

This pre-filters the grid when the logged in user is a manager. The issue I'm having is it will always pre-filter the grid even if the logged in user isn't a manager. So although the data itself won't be filtered, it will still appear as if the Manager column is being filtered.

 

https://ibb.co/FX3c6Qb

 

So is it possible to only apply the filter if the current user is a manager only? If it's just a regular user then don't apply the filter. 

 

Thanks as always.

 

 

 

 

Jamie
Top achievements
Rank 1
 answered on 27 Jun 2019
7 answers
1.6K+ views
I have a Kendo Grid that opens a Template Pop-up when the user clicks Update.  I need to pass an ID to the pop-up or I need to trigger a change on the AccountID dropdownlist to populate the Contacts Grid, but I'm failing on both accounts.  What is the solution?

Here's my Home Index.cshtml:
@using Kendo.Mvc.UI.Fluent
@model PosPayAndBankRec.Models.TreasuryCreateModel
 
@functions {
 
    private void AccountGridCommandDef(GridColumnFactory<PosPayAndBankRec.Models.TreasuryCreateItem> columns)
    {
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
        columns.Bound(p => p.AccountID).Hidden();
        columns.Bound(p => p.BankID).Hidden();
 
        columns.Bound(p => p.BankName).Title("Bank").Width(120);
        columns.Bound(p => p.RamQuestBankNumber).Title("Bank #").Width(60);
        columns.Bound(p => p.AccountName).Title("Account").Title("Location");
        columns.Bound(p => p.AccountNumber).Title("Acct #");
        
        columns.Bound(p => p.PpStatus).Title("Positive Pay");
        columns.Bound(p => p.BrStatus).Title("Bank Rec");
        //columns.Bound(p => p.AccountFolderName).Title("Folder");
    }
 
    private void AccountGridDataSource(DataSourceBuilder<PosPayAndBankRec.Models.TreasuryCreateItem> dataSource)
    {
        dataSource.Ajax()
        .Model(AjaxAccountDataSourceBuilder)
        .Sort(sort => sort.Add(p => p.BankName))
        .ServerOperation(true)
        .Create(create => create.Action("Create", "Home"))
        .Read(read => read.Action("Read", "Home", new { id = Request.QueryString["id"] }))
        .Update(update => update.Action("Edit", "Home"))
        .Destroy(destroy => destroy.Action("Delete", "Home"));
        //.Events(e => e.Error("error"));
    }
 
    private void AjaxAccountDataSourceBuilder(DataSourceModelDescriptorFactory<PosPayAndBankRec.Models.TreasuryCreateItem> model)
    {
        model.Id(p => p.AccountID);
        model.Field(p => p.AccountName);
    }
 
    private void AccountGridToolBarDef(GridToolBarCommandFactory<PosPayAndBankRec.Models.TreasuryCreateItem> toolbar)
    {
        toolbar.Create().Text("Treasury Request");
    }
}
 
@{ ViewBag.Title = "Treasury Connections"; }
@(Html.Kendo().Grid<PosPayAndBankRec.Models.TreasuryCreateItem>()
           .Name("Treasuries")
           .Columns(AccountGridCommandDef)
           .DataSource(AccountGridDataSource)
           .ToolBar(AccountGridToolBarDef)
           .Editable(c => c.Mode(GridEditMode.PopUp).Enabled(true).DisplayDeleteConfirmation(true).Window(window => window.Title("Treasury Request")).TemplateName("TreasuryPopup").AdditionalViewData(new { Banks = Model.Banks }))
           .Sortable()
           .Filterable()
           .Resizable(resize => resize.Columns(true))
           .Reorderable(reorder => reorder.Columns(true))
           .ClientDetailTemplateId("ContactDetails")
           .Pageable(p => p.Enabled(false))
           .Scrollable(s => { s.Height(700); s.Virtual(true); })
             )
</script>
       
 
 
<script id="ContactDetails" type="text/kendo-tmpl">
                    @(Html.Kendo().Grid<PosPayAndBankRec.Models.ContactDetailsModel>()
                            .Name("Details_#=BankID#")
                            .Columns(columns =>
                                        {
                                            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
                                            columns.Bound(p => p.ContactName).Width(150);
                                            columns.Bound(p => p.ContactType).Width(100);
                                            //columns.Bound(p => p.ContactEmail).Width(150);
                                            columns.Bound(p => p.ContactPhone).Width(100);
                                            columns.Bound(p => p.Description).Width(100);
                                             
                                            //columns.Bound(p => p.ContactNotes).Width(200);
                                        })
                            .ToolBar(p => p.Create())
                            .DataSource(dataSource => dataSource
 
                            .Ajax()
                            .Model(model => model.Id(p => p.BankID))
                            .Sort(sort => sort.Add(p => p.ContactName))
                            .ServerOperation(true)
                            .Create(create => create.Action("Create", "Contact"))
                            .Read(read => read.Action("Details", "Contact", new { id = "#=BankID#" }))
                            .Update(update => update.Action("Update", "Contact"))
                            .Destroy(destroy => destroy.Action("Delete", "Contact"))
                        )
 
                            .Pageable()
                            .Sortable()
                            .Resizable(resize => resize.Columns(true))
                            .Reorderable(reorder => reorder.Columns(true))
                            .Editable(c => c.Mode(GridEditMode.PopUp).Enabled(true).DisplayDeleteConfirmation(true).Window(window => window.Title("Contact")).TemplateName("ContactPopup").AdditionalViewData(new { Banks = Model.Banks }))
                            .ToClientTemplate())
            .ToClientTemplate())
</script>


Here's the TreasuryPopup.cshtml:

@using System.Collections
@using PosPayAndBankRec.Models
 
@model PosPayAndBankRec.Models.TreasuryCreateItem
 
@{
    ViewBag.Title = "Treasury";
}
 
 
<fieldset>
    <legend>Bank Account Info</legend>
<table id="table">
    <tr>
        <th>
            Bank
        </th>
        <td>
            @(Html.Kendo().DropDownListFor(model => model.BankID)
                  .Name("BankID")
                  .OptionLabel("-- Select Item --")
          .DataTextField("BankName")
          .DataValueField("BankID")
          .DataSource(source => {
               source.Read(read =>
                               {
                                   read.Action("GetCascadeBanks", "Home");
                               });
          })
                   
                  
        </td>
    </tr>
    <tr>
        <th>
            Location
        </th>
        <td colspan="2">
            <script type="text/javascript">
 
//                function ShowHide(chk,txt) 
//                {
//                    if ((document.getElementById(chk).checked))
 
//                        document.getElementById(txt).style.display='';  
//                    else
//                        document.getElementById(txt).style.display='none';
//                }
 
 
                $(document).ready(function () {
                    $("#AccountID").trigger("valueChange");
                });
 
            </script>
             
            @(Html.Kendo().DropDownListFor(model => model.AccountID)
                   .Name("AccountID")
           .OptionLabel("-- Select Item --")
           .DataTextField("AccountName")
           .DataValueField("AccountID")
           .DataSource(source => {
                                     source.Read(read =>
                                                     {
                                                         read.Action("GetCascadeAccounts", "Home")
                                                             .Data("getBankID");
                                                     })
                                         .ServerFiltering(true);
           })
           .Enable(false)
           .AutoBind(false)
                   .CascadeFrom("BankID")
           .Events(events => events.Change("onBankChange")
           )
                  )
        </td>
    </tr>
    <tr>
        <td>
             
        </td>
        <th>
            Active
        </th>
        <th>
            Deactive
        </th>
    </tr>
    <tr>
        <th>
            Bank Reconcilliation
             
        </th>
        <td>
            @Html.EditorFor(model => model.BrActivationDate)
        </td>
        <td>
             @Html.EditorFor(model => model.BrDeactivationDate)
        </td>
    </tr>
    <tr>
        <th>
            Positive Pay
        </th>
        <td>
 
            @Html.EditorFor(model => model.PpActivationDate)
 
        </td>
        <td>
             @Html.EditorFor(model => model.PpDeactivationDate)
        </td>
    </tr>
</table>
</fieldset>
 
 
 
<fieldset>
    <legend>Contacts</legend>
 
@(Html.Kendo().Grid<PosPayAndBankRec.Models.ContactDetailsModel>()
.Name("Contacts")
                            .Columns(columns =>
                                        {
                                            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
                                            columns.Bound(p => p.ContactName).Width(150);
                                            columns.Bound(p => p.ContactType).Width(100);
                                            //columns.Bound(p => p.ContactEmail).Width(150);
                                            columns.Bound(p => p.ContactPhone).Width(100);
                                            //columns.Bound(p => p.Description).Width(100);
                                            //columns.Bound(p => p.ContactNotes).Width(200);
                                        })
                            .ToolBar(p => p.Create())
                            .DataSource(dataSource => dataSource
                            .Ajax()
                            .Model(model => model.Id(p => p.BankID))
                            .Sort(sort => sort.Add(p => p.ContactName))
                            .ServerOperation(true)
                            .Create(create => create.Action("Create", "Contact"))
                                .Read(read => read.Action("GetCascadeContacts", "Home")
 
                            .Data("getBankID"))
                            .Update(update => update.Action("Edit", "Contact"))
                            .Destroy(destroy => destroy.Action("Delete", "Contact"))
                        )
                        //.AutoBind(false)
                            .Pageable()
                            .Sortable()
                            .Resizable(resize => resize.Columns(true))
                            .Reorderable(reorder => reorder.Columns(true))
                       .Editable(c => c.Mode(GridEditMode.PopUp).Enabled(true).DisplayDeleteConfirmation(true).Window(window => window.Title("Contact")).TemplateName("ContactPopup")))
</fieldset>


Here's the HomeController:

public ActionResult GetCascadeContacts([DataSourceRequest] DataSourceRequest request, int BankID)
        {
 
                var ortcontacts = from contact in db.ORTContacts
                                  join bank in db.ORTBanks on contact.BankID equals bank.BankID
                                  where contact.BankID == BankID
 
                                  orderby contact.ContactName
 
                                  select new TreasuryCreateItem()
                                  {
                                      ContactID = contact.ContactID,
                                      ContactName = contact.ContactName,
                                      ContactEmail = contact.ContactEmail,
                                      ContactPhone = contact.ContactPhone,
                                      ContactType = contact.ContactType,
                                      ContactNotes = contact.ContactNotes,
                                      BankID = contact.BankID,
                                      BankName = bank.BankName
                                  };
                return Json(ortcontacts.ToDataSourceResult(request));
 
        }


Here's the TreasuryCreateModel:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PosPayAndBankRec.Domain.Models;
using System.ComponentModel.DataAnnotations;
using PosPayAndBankRec.Models.Validators;
 
namespace PosPayAndBankRec.Models
{
    public class TreasuryCreateItem
    {
        public int AccountID { get; set; }
        public int BankID { get; set; }
        public string BankName { get; set; }
        [Required]
        [UniqueAccountName("This bank is already named in the system.")]
        [DataType(DataType.Text)]
        public string BankAccountName { get; set; }
        [Required]
        [UniqueAccountName("This account is already named in the system.")]
        [DataType(DataType.Text)]
        public string AccountName { get; set; }
        public string AccountNumber { get; set; }
        public string RamQuestBankNumber { get; set; }
        public string ContactType { get; set; }
        public string Description { get; set; }
        public int ContactID { get; set; }
        public string ContactName { get; set; }
        public string ContactPhone { get; set; }
        public string ContactEmail { get; set; }
        public string ContactNotes { get; set; }
        public bool? HasPosPay { get; set; }
        public bool? HasBankRec { get; set; }
        public string BrStatus { get; set; }
        public string PpStatus { get; set; }
        public string BrStatusNotes { get; set; }
        public string PpStatusNotes { get; set; }
        public Nullable<System.DateTime> BrActivationDate { get; set; }
        public Nullable<System.DateTime> BrDeactivationDate { get; set; }
        public Nullable<System.DateTime> PpActivationDate { get; set; }
        public Nullable<System.DateTime> PpDeactivationDate { get; set; }
        public List<ORTBank> Banks { get; set; }
    }
 
    public class TreasuryCreateModel
    {
        public List<ORTBank> Banks { get; set; }
        public List<ORTAccount> Accounts { get; set; }
        public List<ORTContact> Contacts { get; set; }
        public IEnumerable<TreasuryCreateItem> TreasuryCreateItems { get; set; }
    }
}


JavaScript:

<script type="text/javascript">
 
            function onBankChange(e) {
                var BankID;
                var bankDropdown = this;
                var contactGrid = $("#Contacts").data("kendoGrid");
 
                // Set BankId to the selected id of the bankDropDown
                BankID = $.map(this.select(), function (item) {
                    var dataItem = bankDropdown.dataItem(bankDropdown.select()).Id;
                });
 
                // Read the datasource again
                contactGrid.dataSource.read();
            }
 
            function getBankID() {
                return {
                    BankID: $("#BankID").val()
                };
            }
 
            function setPopupDimensions(ev) {
 
                window.setTimeout(function () {
 
                    $(".k-edit-form-container").parent().width(800).height(400).data("kendoWindow").center();
                }, 100);
 
            }
        </script>



Tsvetomir
Telerik team
 answered on 26 Jun 2019
3 answers
271 views

Is there an example of how to render a bar code widget in a pdf export header using a kendo template? I'm using MVC/Razor.

 

This does not work

 

<script type="x/kendo-template" id="page-template">
    <div class="pdf-page-template">
        <div class="header">
            <h1>My Order</h1>

    <div>@(Html.Kendo().Barcode().Name("gudbrands").Value(Model.OrderNumber).Encoding(BarcodeSymbology.Code39).Width(280).Height(100))</div>
                <div><strong>Order Number</strong> @Model.Header.OrderNumber
        </div>
    </div>
</script>

Georgi
Telerik team
 answered on 26 Jun 2019
2 answers
876 views

Hello,
Our app displays many numbers and we often use the kendo.toString function according to https://docs.telerik.com/kendo-ui/globalization/intl/numberformatting 
In some places we use it with the format ##,# (to display integers) and in others we use ##,#.00 to always print the decimal part.


Here are two examples:
kendo.toString(12345.10, "##,#”) >>”12,345"
kendo.toString(12345.10, "##,#.00”) >> "12,345.10"
In certain area we wish to be able and present integers as integers, and without the decimal part, and present floats with two decimal parts.
Clearly we cannot use any of the suggested format. Using ##,# only gives integers and ##,#.00 will turn 10 into 10.00 while we wish to keep it as 10


We also cannot use ##,#.## because we cannot allow only 1 decimal digit. The result of kendo.toString(10.1, "##,#.##”) is “10.1” but we must have it as “10.10” because we need either 0 decimal figures or 2.


Is there a format that can answer this need?

 

Thanks,

Ron.


Ron
Top achievements
Rank 1
Veteran
 answered on 25 Jun 2019
2 answers
481 views

Good Afternoon,

I've run into a bit of a strange issue and I'm not entirely sure what the cause could be.

We want to use the Kendo Chat widget to power our in-app messaging service, but I've run into an issue that is causing me a bit of stress with the implementation.

When rendering messages, it does not correctly fill the chat area, causing the messages to be rather squished and the datestamps to be rendered partially outside of the container.  If I input a long message, this area will grow, but it will grow to the point where the avatar image is pushed out of the right side of the chat area, and the timestamp remains hidden to the left.  I have attached images of both of these behaviors.

This chat widget is being rendered inside of a KendoUI window and I have updated to the newest NPM release, if that makes any difference.  

We are using Aurelia w/ Typescript, but as this has not yet been added to the Aurelia-KendoUI bridge, the chat widget is being initialized programatically with JQuery.  Any insight as to why this is behaving this way would be appreciated.

The window initialization is as follows:

<div id.bind="'chatWindow' + cUser.Thread.ThreadID"
     ak-window="k-width: 300px; k-height:400px; k-title: Messenger; k-resizable.bind: false; k-visible.bind: false; k-actions.bind: actions; k-widget.bind: chatWindows[cUser.Thread.ThreadID]"
     k-on-close.delegate="onClose()">
  <chat-window chat-thread.bind="cUser.Thread"></chat-window>
</div>
openChat(threadID)
{
  this.chatWindows[threadID].center().open();
}

 

And the chat widget initialization is:

<div id.bind="'chat' + ChatThread.ThreadID" style="height:100%;width:100%"></div>
private createChat() {
    if (!App.myUser) {
      setTimeout(() => this.createChat(),500);
      return;
    }
 
    let companyUserID = App.myUser.CompanyUsers[0].CompanyUserID;
 
    let user = this.getUserByUserID(App.myUser.UserID);
 
    let chat = $("#chat" + this.ChatThread.ThreadID).kendoChat({
      // Each instance of the app will generate a unique username.
      // In this way, the SignalR Hub "knows" who is the user that sends the message
      // and who are the clients that have to receive that message.
      user: {
        name: user!= null ? user.Contact.FirstName + " " + user.Contact.LastName : null,
        iconUrl:user!= null ?  user.AvatarURL : null
      },
      // This will notify the SignallR Hub that the current client is typing.
      // The Hub, in turn, will notify all the other clients
      // that the user has started typing.
      typingStart: function () {
        //chatHub.invoke("sendTyping", chat.getUser());
      },
      // The post handler will send the user data and the typed text to the SignalR Hub.
      // The Hub will then forward that info to the other clients.
      post: function (args) {
        //chatHub.invoke("send", chat.getUser(), args.text);
      }
    }).data("kendoChat");
    for (let message of this.ChatThread.Messages)
    {
      if(message.CreatedByUserID == App.myUser.UserID)
      {
        let myUser = chat.getUser();
 
        chat.renderMessage({type:'text',text:message.Message,timestamp:message.Timestamp},myUser);
        continue;
      }
 
      let user = this.getUserByUserID(message.CreatedByUserID);
 
      chat.renderMessage({type:'text',text:message.Message,timestamp:message.Timestamp},{
        id: user.UserID,
        name: user != null ? (user.Contact.FirstName + " " + user.Contact.LastName) : null,
        iconUrl: user != null ? user.AvatarURL: null});
    }
  }
Jay
Top achievements
Rank 1
 answered on 25 Jun 2019
7 answers
534 views

I have several events on the same day (allday), and I have a requirement to move all events from one day to another.

I know that today it is possible to hold the CTRL key and select one by one, but I would like to know if there is any feature to select all from the same day.
Or if it does not exist, I can put a button below the day for the user click, and i do this programmatically.

Thank you.

ziental
Top achievements
Rank 1
 answered on 25 Jun 2019
6 answers
1.2K+ views

As it stands, the menu filter dropdown Null checkbox doesn't return any of the grids Null values. Is there a way to correct the filters operator or to even remove the checkbox option to filter by Null?

 

https://i.ibb.co/9qr5Vwr/2.png

 

I've had a look through the forum and couldn't find an official response to deal with this issue, there was this thread but I've not stumbled across these filter options before and I'm not interested in updating base code as we reference the most recent kendo from your repos. https://www.telerik.com/forums/multi-filter-with-null-values---they-are-not-visible

 

Thanks in advance.

Jamie
Top achievements
Rank 1
 answered on 25 Jun 2019
2 answers
641 views
I have a Kendo UI treeview with a select handler. Right now, everything works if I select a node manually, but if I use the select method (http://docs.kendoui.com/api/web/treeview#select) my handler isn't triggered. Am I doing something wrong, or is this intended?
Also, is there a way to trigger the select event handler in code after selecting the element?
Thanks
David
Top achievements
Rank 1
 answered on 24 Jun 2019
1 answer
123 views

     Hi, I am trying to create a vertical group and have all events be color-coded based upon the type of event. I put together a Dojo as an example:

https://dojo.telerik.com/eMUHurex

 

You can see that the events are being grouped by 'Vehicle', but the color coding is not being applied based upon the type of event. If you remove the first resource item, the color coding will be applied correctly. Is there a configuration which I am missing, or does the scheduler not support this functionality? 

 

Thanks!

Ivan Danchev
Telerik team
 answered on 24 Jun 2019
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?