Telerik Forums
Kendo UI for jQuery Forum
1 answer
218 views

Hello,

I'm trying sort by date my data, but is not working. I already tried a lot of approach but none work.

Expiration Date is a date

Expiration Date Format is a string, so don't give to sort.

Please help me, what is wrong? 

Strange that in another site is working this approach.

Pedro
Top achievements
Rank 1
Iron
 answered on 17 Feb 2023
1 answer
136 views

my column defination for kendo grid

columns: [
                    { field: "centreName", title: "Centre Name", width: "180px" },
                    { field: "address", title: "Address", width: "188px", encoded: false },
                    { field: "programme", title: "Programme", width: "180px", encoded: false },
                    { field: "action", width: "180px", encoded: false }
                ],

I don't want to print the column title for action

current output is

Grid Header Columns

Neli
Telerik team
 answered on 17 Feb 2023
0 answers
152 views
Is it possible to embed the kendo spread sheet within webpage in display mode? 
Rajendran
Top achievements
Rank 1
 asked on 17 Feb 2023
1 answer
905 views

Hi, I recently created a grid with a multiselect filter and noticed that the selected values are not showing if the user selects more than one item and then filters. I could reproduce the behaviour in a short dojo script which comes from the telerik examples.

Is there any reason for this behaviour or did I forget something that makes the filter control fail? If this is a bug, is there a workaround?

In the example, the field that contains the filter is "Name" (2nd column).

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2023.1.117/styles/kendo.default-ocean-blue.min.css">
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2023.1.117/js/angular.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2023.1.117/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2023.1.117/js/kendo.all.min.js"></script>
</head>
<body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore-min.js"></script>
    <div id="grid"></div>
    <script>
      var data = [
        { id: 1, name: "Fred", key: 1, value: "Green" },
        { id: 2, name: "Jed", key: 11, value: "Jorgensen" },
        { id: 3, name: "Red", key: 2, value: "Blah" },
        { id: 4, name: "Ted", key: 23, value: "Bleh" },
        { id: 5, name: "Ed", key: 3, value: "Toast" },
        { id: 6, name: "Zed", key: 4, value: "Smith" },
        { id: 7, name: "Ed", key: 41, value: "Johnson" }
      ];

      $(function() {
        var names = _.sortBy(_.uniq(_.pluck(data, "name")), function(n) { return n; });

        function createMultiSelect(element) {         
          element.kendoMultiSelect({
            dataSource: names
          });
        }

        var dataSource = new kendo.data.DataSource({
          data: data,
          schema: {
            model: {
              fields: {
                id: { type: "number" },
                name: { type: "string" },
                key: { type: "number" },
                value: { type: "string" }
              }
            }
          }
        });

        var grid = $("#grid").kendoGrid({
          dataSource: dataSource,
          sortable: true,
          filterable: true,
          columns: [
            {field: "id", title: "Id"},
            {
              field: "name",
              title: "Name",
              filterable: {
                ui : createMultiSelect,
                extra: false
              }
            },
            {field: "key", title: "Key"},
            { field: "value", title: "Value"}
          ]
        });
      });
    </script></body>
</html>
Martin
Telerik team
 answered on 16 Feb 2023
0 answers
102 views

I have a Kendo grid Jquery component with field grouped and hidden. I would like to show a filter button based on this field. Could you help me ?

Thanks

Alex
Top achievements
Rank 1
 asked on 16 Feb 2023
1 answer
186 views
Hey, when I open chart it opens the chart in zoom in.
How can I set the initial level zoom, that when I go in it will show me the whole chart ? (without scrolling for zoomout)
Nikolay
Telerik team
 answered on 16 Feb 2023
1 answer
170 views

Hi,

We're migrating from ASP.NET AJAX to Kendo UI for jQuery. We've been able to migrate most controls to widgets. However, we're having an issue with filtering. We're trying to replicate the filter template feature in RadGrid in the demo here https://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx . We've looked at using the filter menu customization in this demo https://demos.telerik.com/kendo-ui/grid/filter-menu-customization . However, we want to use the filter in "row" mode, instead of a filter button / menu with the options in it. Our end users find it quite clunky and requires a few extra clicks which takes away from the user experience. Is there any options besides the filter menu in the mentioned demo?

Thanks

 

Georgi Denchev
Telerik team
 answered on 15 Feb 2023
1 answer
2.4K+ views

I am using dart sass to try to apply my custom colors, but it doesn't want to override the file per the documented instructions. In the first example, it does compile but the color isn't overridden in the file.

Using package sass v1.58.0

This doesn't override the primary color:

$primary: #4dcae6;

@import "~@progress/kendo-theme-default/dist/all.scss";

Apparently you can use the @use statement with a `with ( ... )` and that's supposed to work, but if I do that, I get the error "This variable was not declared with !default in the @used module.". I'm stuck.

@use "@progress/kendo-theme-default/dist/all.scss" with (
    $primary: #4dcae6
)
Ivan Zhekov
Telerik team
 answered on 15 Feb 2023
1 answer
663 views

I am using a dropdownlist widget in an ajax form used to edit an object. When the form loads, I need to initialize the dropdown, set its datasource, and programmatically set the selected dropdown item based on two values (compound key). However,  the return statement in my ddAssignee.select(function()) does not execute, so nothing gets selected. I checked the contents of ddAssignee.dataSource.view() immediately after calling setDataSource() and it was empty, so I'm assuming this is why nothing gets selected. However, I have a separate button that is  used to select the dropdown item after the form loads ("Take It" button), which works fine. I'm just trying to figure out what is missing after setting the datasource that is causing the dataSource.view() to still be empty. 

UPDATE: I overlooked this info about select(): 

  • If the widget is not bound (e.g. autoBind is set to false), the select method will not pre-fetch the data before continuing with the selection and value setting (unlike the value method), and no item will be selected.

            However, setting autoBind to true still does not solve the problem.

I have attached:

-Screenshot of the edit form

-Edit form html with ajax form

-InitAssigneeDropdown() basic dropdown initialization

-GetAllAssigneesDataSource() returns the remote data for the dropdown via kendo.data.DataSource

- onEditTask function (executes when button is clicked to open the edit form - where issue happens)

- "Take It" button event (where select(function()) works successfully)

Any help is greatly appreciated. Thanks! 


@model Models.Tasking.TaskModel

<div class="modal-content">

    @using (Ajax.BeginForm("SaveEditTask", "Tasking", null, new AjaxOptions()
    {
        UpdateTargetId = "frmEditTask",
        InsertionMode = InsertionMode.Replace,
        OnSuccess = "taskingSaveSuccess"
    }, new { id = "frmEditTask", autocomplete = "off" }))
    {
        <div class="modal-header">
            <h5 class="modal-title" id="modalTitle">Edit Task</h5>
        </div>
        <div class="modal-body" style="max-height:70vh; overflow-y:auto">
            @Html.AntiForgeryToken()

            @Html.ValidationSummary(false, "", new { @class = "text-danger" })

            @Html.HiddenFor(m => m.ID)
            @Html.HiddenFor(m => m.PtOID)
            @Html.HiddenFor(m => m.PtMRN)
            @Html.HiddenFor(m => m.CreatedByUserFK)
            @Html.HiddenFor(m => m.CreatedDTTM)

            <div class="form-group">
                @Html.LabelFor(m => m.PtFullName, new { @class = "text-dark font-weight-bold" })
                @Html.TextBoxFor(m => m.PtFullName, new { @class = "form-control mb-2", @readonly = "readonly" })
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.TypeFK, new { @class = "text-dark font-weight-bold" })
                @Html.DropDownListFor(m => m.TypeFK, (IList<SelectListItem>)ViewBag.TaskTypeOptions, new { @class = "form-control p-1 w-auto mb-2", @disabled = "disabled", @readonly = "readonly" })
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.StatusFK, new { @class = "text-dark font-weight-bold" })
                <br />
                @Html.DropDownListFor(m => m.StatusFK, (IList<SelectListItem>)ViewBag.TaskStatusOptions, new { @id = "ddTaskStatusType", @class = "form-control p-1 w-auto mb-2" })
            </div>
            <div class="form-group">
                @Html.LabelFor(m => m.PriorityFK, new { @class = "text-dark font-weight-bold" })
                <br />
                @Html.DropDownListFor(m => m.PriorityFK, (IList<SelectListItem>)ViewBag.TaskPriorityOptions, new { @id = "ddTaskPriorityType", @class = "form-control p-1 w-auto mb-2", data_default_due_date_url = Url.Action("GetDefaultDueDate", "Tasking", new { area = "" }) })
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.DueDTTM, new { @class = "text-dark font-weight-bold" })
                @if (Model.CreatedByUserFK == User.Identity.GetUserId())
                {
                    @(Html.Kendo().DateTimePickerFor(m => m.DueDTTM).HtmlAttributes(new { @id="dtpTaskDueDate", data_toggle = "tooltip", data_placement = "bottom", data_trigger = "focus", required = "required" }))
                }
                else
                {
                    @Html.TextBoxFor(m => m.DueDTTM, new { @class = "form-control mb-2", @readonly = "readonly" })
                }
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.AssigneeFK, new { @class = "text-dark font-weight-bold" })
                <br />
                <div class="row">
                    <div class="col-9 pr-0">
                        <select id="ddTaskAssignee" name="AssigneeFK" data-all-assignees-url="@Url.Action("GetAllTaskAssigneeOptions", "Tasking", new { area = "" })" />
                    </div>
                    <div class="col-3 pl-2">
                        <button id="btnSelfAssignTask" type="button" class="btn btn-secondary" data-user-id-url="@Url.Action("GetUserId", "Tasking", new { area = "" })">Take It</button>
                    </div>
                </div>
                @Html.HiddenFor(m => m.AssigneeTypeFK, new { @id = "hiddenAssigneeTypeFK" })
            </div>

            <div class="form-group">
                @Html.LabelFor(m => m.Description, new { @class = "text-dark font-weight-bold" })
                @if (Model.CreatedByUserFK == User.Identity.GetUserId())
                {
                    @Html.TextAreaFor(m => m.Description, new { @class = "form-control" })
                }
                else
                {
                    @Html.TextAreaFor(m => m.Description, new { @class = "form-control", @readonly = "readonly" })
                }
            </div>

        </div>

        <div class="modal-footer">
            @if (Model.CreatedByUserFK == User.Identity.GetUserId())
            {
                <button id="btnDeleteTask" type="button" class="btn btn-danger" data-target-url="@Url.Action("DeleteTask", "Tasking", new { area = "" })">Delete Task</button>
            }
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
            <button type="submit" class="btn btn-primary">Save</button>
        </div>
    }

</div>
function initAssigneeDropDown() {
    $("#ddTaskAssignee").kendoDropDownList({
        optionLabel: 'Select Assignee ...',
        filter: "contains",
        dataTextField: 'AssigneeName',
        dataValueField: 'AssigneeFK',
        template: function (dataItem) {
            //TODO - improve logic
            if (dataItem.AssigneeTypeFK == 1)
                return '<span><i class="fas fa-user pr-2"></i>' + dataItem.AssigneeName + '</span>';
            else if (dataItem.AssigneeTypeFK == 2)
                return '<span><i class="fas fa-users pr-2"></i>' + dataItem.AssigneeName + '</span>';
        }
    });
}
function getAllAssigneesDataSource() {
    var url = $('#ddTaskAssignee').data('all-assignees-url');

    var dataSource = new kendo.data.DataSource({
        transport: {
            read: {
                type: "POST",
                url: url
            }
        }
    });

    return dataSource;
}
function onEditTask(e) {
    //Fetch the ID, assigneeTypeFK, and assigneeFK from the grid item that's getting edited
    var grid = $('#taskGrid').data('kendoGrid');
    var taskDataItem = grid.dataItem($(e).closest("tr"));
    var taskId = taskDataItem.ID;
    var assigneeTypeFK = taskDataItem.AssigneeTypeFK;
    var assigneeFK = taskDataItem.AssigneeFK; 

    $('#taskModal').modal('show'); //Show the edit modal

    $('#taskModal .modal-content').html(''); //Clear out the modal container

    //ajax to return partial view for editing task
    $.ajax({
        url: $(e).data("target-url"), 
        type: "POST",
        cache: false,
        data: JSON.stringify({ taskId: taskId }), //Pass the task id to controller
        contentType: "application/json; charset=utf-8",
        success: function (response) {
            $('#taskModal .modal-content').replaceWith(response); //add edit view html to modal

            initAssigneeDropDown();
            var ddAssignee = $('#ddTaskAssignee').data('kendoDropDownList');
            ddAssignee.setDataSource(dataSource);
            var assigneeDataSourceView = ddAssignee.dataSource.view(); //Issue - this is empty so select (below) will not work

            ddAssignee.select(function (dataItem) {
                return dataItem.AssigneeTypeFK == assigneeTypeFK && dataItem.AssigneeFK == assigneeFK;
            });

        },
        error: function (jqXHR, exception) {
            if (jqXHR.statusText !== 'abort') {
                // Our error logic here
                $('#kNotification').data('kendoNotification').error("An error occurred while loading the page.");
            }
        }
    });
    
}
$('#taskModal').on('click', '#btnSelfAssignTask', function (e) {
 
    //Ajax to return the current user's ID from the controller
    $.ajax({
        url: $(e.currentTarget).data("user-id-url"),
        type: "POST",
        cache: false,
        contentType: "application/json; charset=utf-8",
        success: function (response) {
            var userId = response;

            //Set the value of the dropdown based on the user's id
            var ddAssignee = $('#ddTaskAssignee').data('kendoDropDownList');
            var assigneeDataSource = ddAssignee.dataSource.view(); //For testing
            //TODO improve logic
            ddAssignee.select(function (dataItem) {
                return dataItem.AssigneeTypeFK == 1 && dataItem.AssigneeFK == userId;
            });
        },
        error: function (jqXHR, exception) {
            if (jqXHR.statusText !== 'abort') {
                $('#kNotification').data('kendoNotification').error("An error occurred while assigning task");
            }
        }
    });

});


Georgi Denchev
Telerik team
 answered on 14 Feb 2023
0 answers
485 views

Hi Guys,

 

I have JQuery, KendoUI ASPNET MVC 5 which has two pages Index and View Details Page each has a dedicated js file and want to return to the previous Grid page number when a button in View Details is clicked:

  • In the first page I search Customer details which populates a table with Customer details { Name, Occupation and Title, a link to the view details} and has pageSize of 10 and multiple pages, depending on the customers stored.
  • What I want to achieve is to be able to return to the previous page results that was selected when and <a> to view details was clicked. For Instance I click <a> element on page number 20, I want to return to page 20 when I click save.

This is what I have tried so far:

  • I used the standard way of saving the page grid in a sessionStorage , retrieving the saved page and assigning it to the current page when save or cancel button is clicked, and assigning the saved grid page number using this method:    kendoGrid.dataSource.page(savedPage).
    • Results:  Returns to the first of results, irrespective of the current save page in the session storage.

    I then attempted to fix the issue by trying to set the page number using the jquery.

    ViewDetails.js

    $(document).ready(function () {

      $("button.isa-button-back, button.isa-button-save").click(function (e) {
        localStorage.setItem("depositButtonClicked", true);
      });
    });

    Index.js

    $(document).ready(function () {
      var filterNumber = $("span.k-state-selected").text();
      localStorage.setItem("filterNumber", filterNumber);
      if (localStorage.getItem("depositButtonClicked") === "true") {
        var storedValue = localStorage.getItem("filterNumber");
        $($("ul.k-pager-numbers li span.k-state-selected")).removeClass(
          "k-state-selected"
        );
        $("ul.k-pager-numbers li span")
          .filter(function () {
            return $(this).text() == parseInt(storedValue);
          })
          .addClass("k-state-selected");
        localStorage.removeItem("storedValue");
        localStorage.removeItem("depositButtonClicked");
      }
    });

    Results: Internal Server Error 500, when I click save or back button in the detailsPage

    Another way that I tried was to use this function in the  CustomerController's method:

             
        public ActionResult Back()
        {

            SetScriptModuleOptions("IndexModule", new { RestoreGrid = true });
            SetScriptModuleOptions("IsaSearchGrid", new { PreserveGridState = GridStatePreservation.All });

            return RedirectToAction("Index");
        }

Moshele
Top achievements
Rank 1
 asked on 14 Feb 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?