Telerik Forums
Kendo UI for jQuery Forum
5 answers
16.2K+ views

Hi!

I'm trying to make an ajax call to my controller function.
To get all the data that currently are in a grid's datasource.
Instead of calling directly to the grid's datasource.data() which only returns me the current grid page.

I go about this by instantiating a new kendo datasource.
But everything i try, yields "Uncaught TypeError: e.slice is not a function"

Thanks in advance.

public JsonResult ReadTimeRegistrationAjax([DataSourceRequest] DataSourceRequest request)
{
   var dataSourceResult = getStuff().ToList();
   return Json(dataSourceResult.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

var grid = $("#GridTimeRegistrations").data("kendoGrid");
        var dataurl = grid.dataSource.transport.options.read.url;
 
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: dataurl,
                    dataType: 'json'
                }
            },
        });         
 
        dataSource.fetch(function() {
            var data = dataSource.data();
            console.log(data);
        }

Mark
Top achievements
Rank 1
 answered on 09 Mar 2021
1 answer
326 views

I have an issue and I need someone to see what I'm doing wrong...

I tried to use several times "reorder". I simplify the test to this :

<!-- container templates -->
  <script id="barcelona" type="text/x-kendo-template">
            A
  </script>
 
<script id="sofia" type="text/x-kendo-template">
            B
</script>
 
 
$("#home-super-container").kendoTileLayout({
                containers: [{
                    colSpan: 1,
                    rowSpan: 1,
                    header: {
                        text: "Barcelona"
                    },
                    bodyTemplate: kendo.template($("#barcelona").html())
                }, {
                    colSpan: 1,
                    rowSpan: 1,
                    header: {
                        text: "Sofia"
                    },
                    bodyTemplate: kendo.template($("#sofia").html())
                }],
                columns: 2,
                columnsWidth: 285,
                rowsHeight: 285,
                reorderable: true,
                reorder: function (e) {
                            console.log(e.newIndex, e.oldIndex);
                }
    });

 

The console.log indicates (0 0), it should be (0 1) or (1 0)...

 

Mihaela
Telerik team
 answered on 09 Mar 2021
2 answers
376 views

Hi,

I have a kendo toolbar with multiple dropdowns and checkboxes to filter my datasource. What I want is when I submit my filter selections, if a spesific checkbox is checked, then datetime column of the grid will have this template:

"#= kendo.toString(kendo.parseDate(dates), 'dd/MM/yyyy') #"

If the checkbox not checked (or the page is just loaded with empty checkbox in default scenario) the column will have:

"#= kendo.toString(kendo.parseDate(dates), 'dd/MM/yyyy HH:mm') #"

as template. 

I tried conditioning inside of grid but I didn't manage to obtain checkbox value. I tried writing a function outside the grid function but when I refresh grid data with:

var grid = $("#grid").data("kendoGrid");
grid.dataSource.data(reportData);

it only refresh the data inside grid, that does not trigger the template function.

How can I change the column template while refreshing the data according to that checkboxs value? 

 

Greets Umutcan

Nikolay
Telerik team
 answered on 09 Mar 2021
8 answers
1.8K+ views
When I have a grid that extends below the visible area of the page, clicking on a row causes the page to scroll upward by some arbitrary amount. My attempt to prevent this in the grid change handler is not successful, because the scroll is instantaneous, and happens before the handler is called. I can scroll the page back down within the handler, but this causes a very noticeable 'jump' when a row is clicked. It appears this only happens in Chrome.

I have two questions:

1. why does the page scroll at all when a row is clicked?
2. how can i PREVENT the scrolling entirely, instead of re-scrolling the page back to the original position?

Here's most of the grid definition:

change: onChange,
sortable: {
mode: 'multiple'
},
groupable: true,
filterable: true,
navigatable: true,
resizable: true,
selectable: 'multiple row',

I've searched a bit, and found a few threads with something that sounds similar (http://www.telerik.com/forums/grid-jumps-or-scrolls-to-top-on-row-click), but the claim is that the issue was resolved with 2013.1.417

Can anyone shed some light on this? Many thanks


Tsvetomir
Telerik team
 answered on 09 Mar 2021
2 answers
228 views

I was having some issues with a grid where I was getting an error saying that Description is not field that can be called on a null value, or something along those lines. TimeType is of type TimeTypeViewModel.

public class TimeTypeViewModel
{
    public override string ID { get; set; }
    public override string Description { get; set; }
}

 

columns.Bound(p => p.TimeType).Hidden(true).ClientTemplate("#= (typeof TimeType != 'undefined') ? TimeType.Description : ''#");

 

but the following code doesn't cause me any issues

but code doesn't cause me any issues

columns.Bound(p => p.TimeType).Hidden(true).ClientTemplate("#= typeof TimeType == 'undefined' || TimeType == null ? '' : TimeType.Description #");

 

Why is this? It seems that all the values (i.e. 'TimeType.Description') are being evaluated in the expression before actually checking to see if they should be evaluated based on the inline if condition. Is this a bug? Is this me not understanding how templates work? Is my code somehow bad, or only works on certain types?

carlos
Top achievements
Rank 1
 answered on 09 Mar 2021
6 answers
326 views

I'm using a Custom Edit Template for my scheduler.

I have two textareas (description & notes) that I would like to be kendo editors. Can this be achieved?

 

<script id="customEditorTemplate" type="text/x-kendo-template">
 
    <div class="content-wrapper">
          
        <!-- code removed for brevity -->
 
        <div class="row m05">
            <div class="col-sm-2 text-right">
                <label for="description">Activity</label>
            </div>
            <div data-container-for="description" class="col-sm-8">
                <textarea name="description" class="k-textbox" required="required" data-bind="value:description"></textarea>
            </div>
        </div>
 
        <div class="row m05">
            <div class="col-sm-2 text-right">
                <label for="notes">Notes</label>
            </div>
            <div data-container-for="notes" class="col-sm-8">
                <textarea id="notes" name="notes" class="k-textbox" data-bind="value:notes"></textarea>
            </div>
        </div>
    
        <div class="row m05">
            <div class="col-sm-2 text-right">
                <label for="recurrenceRule">Repeat</label>
            </div>
            <div data-container-for="recurrenceRule" class="col-sm-8">
                <div data-bind="value:recurrenceRule" name="recurrenceRule" data-role="recurrenceeditor"></div>
            </div>
        </div>   
    </div>
 
</script>
Veselin Tsvetanov
Telerik team
 answered on 08 Mar 2021
1 answer
508 views

Using a Kendo Grid to do inline editing.  It works absolutely great and love everything Kendo brings to the table.  I'm working on doing some refactoring and trying to remove as much duplicate code from an application because ... well because it needs to happen.  :-)

So I'm curious, is there a way to specify default values for transport.  For example, below you can see a Read, Update, Destroy and in each case I have to set the content type, send auth tokens in the header, etc.

Thanks,

Richard

transport: {
                    // eslint-disable-next-line consistent-return
                    parameterMap: function (data, type) {
                        if (type !== "read" && data) {
                            return kendo.stringify(data);
                        }
                    },
                    read: {
                        url: "https://api.domain.com/Billings/",
                        dataType: "json",
                        beforeSend: function (xhr) {
                            xhr.setRequestHeader("TOKEN", "SomethingHere");
                            xhr.setRequestHeader("SECRET", "SomethingHere");
                        }
                    },
                    update: {
                        type: "PUT",
                        url: "https://api.domain.com/Billing",
                        dataType: "json",
                        contentType: "application/json;charset=utf-8",
                        beforeSend: function (xhr) {
                            xhr.setRequestHeader("TOKEN", "SomethingHere");
                            xhr.setRequestHeader("SECRET", "SomethingHere");
                        }
                    },
                    destroy: {
                        type: "DELETE",
                        url: "https://api.domain.com/Billing",
                        dataType: "json",
                        contentType: "application/json;charset=utf-8",
                        beforeSend: function (xhr) {
                            xhr.setRequestHeader("TOKEN", "SomethingHere");
                            xhr.setRequestHeader("SECRET", "SomethingHere");
                        }
                    }
},

 

Georgi
Telerik team
 answered on 08 Mar 2021
1 answer
94 views

Hello,

I figured out that when I put a foreign key column under a multi-column header, it does not connect to the reference data source and shows raw foreign keys (numbers) instead.

Please see https://dojo.telerik.com/ipObEVAG for the example (made out of foreign key example).

Do I miss something or is it a bug?

Thanks.

Eyup
Telerik team
 answered on 08 Mar 2021
3 answers
1.0K+ views

Hi Quite new to Telerik UI for Jquery.  Trying to get an inline edit grid with ajax source. But for some reason all the rows are empty even though the ajax json result is not empty. 

Have reference the demo Inline editing in https://demos.telerik.com/kendo-ui/grid/editing-inline but still unable to identify the issue. Here's my code below. Does any one know wat the issue is? or point me in the right direction? P.S can ignore the transport links... once I get read to work, then can move on to other links..

Thanks.

 

01.var crudServiceBaseUrl = "";
02.           dataSource = new kendo.data.DataSource({
03.               transport: {
04.                   read: {
05.                       url: "@Url.Action("KendoGrid_Read","Admin")",
06.                       dataType: "json"
07.                   },
08.                   update: {
09.                       url: crudServiceBaseUrl + "/Products/Update",
10.                       dataType: "jsonp"
11.                   },
12.                   destroy: {
13.                       url: crudServiceBaseUrl + "/Products/Destroy",
14.                       dataType: "jsonp"
15.                   },
16.                   create: {
17.                       url: crudServiceBaseUrl + "/Products/Create",
18.                       dataType: "jsonp"
19.                   },
20.                   parameterMap: function(options, operation) {
21.                       if (operation !== "read" && options.models) {
22.                           return {models: kendo.stringify(options.models)};
23.                       }
24.                   }
25.               },
26.               batch: true,
27.               pageSize: 20,
28.               schema: {
29.                   data: "data",
30.                   total: "total",
31.                   errors: "errors",
32.                   model: {
33.                       fields: {
34.                           id:"CompanyId",
35.                           CompanyId: { type:"number", editable: false, nullable: false },
36.                           CompanyName: { type: "string", editable: false },
37.                           CompanyGroupId: { type:"number", editable: false },
38.                           IsActive: { type: "boolean" },
39.                           Multiplier: { type: "number", validation: { min: 0, required: false } }
40.                       }
41.                   }
42.               }
43.           });
44. 
45. 
46.           $("#grid").kendoGrid({
47.               dataSource: dataSource,
48.               pageable: true,
49.               height: 550,
50.               toolbar: ["create"],
51.               columns: [
52.                   { field: "CompanyName", title: "Company Name" },
53.                   { field: "CompanyGroupId", title: "Unit Price" },
54.                   { field: "Multiplier", title: "Multiplier" },
55.                   { field: "IsActive", title: "Is Active", width: "120px" },
56.                   { command: ["edit", "destroy"], title: " " }
57.               ],
58.               editable: "inline"
59.           });
60.       });

 

SkyyCipp
Top achievements
Rank 1
 answered on 07 Mar 2021
14 answers
1.9K+ views

https://docs.telerik.com/kendo-ui/controls/editors/dropdownlist/how-to/selection/disable-items-for-selection

 

{field: 'operDay', title: '조업요일', width: 100, editor: _this.columnEditor.dayDropDownEditor}
dayDropDownEditor : function (container, options) {
    $('<input id="' + options.field + '" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            suggest: true,
            dataSource: [
                {id:'1', name:'월요일', operDay: '월요일', isDeleted: false },
                {operDay: '화요일', isDeleted: false },
                {operDay: '수요일', isDeleted: false },
                {operDay: '목요일', isDeleted: false },
                {operDay: '금요일', isDeleted: false },
                {operDay: '토요일', isDeleted: false },
                {operDay: '일요일', isDeleted: false }
            ],
            dataTextField: 'operDay',
            dataValueField: 'operDay',
            valuePrimitive: true,
            select: function(e){
                if(e.dataItem.isDeleted){
                    e.preventDefault();
                    alert("why?");
                }
            },
            template: kendo.template($("#template").html())
 
        });
}

 

Hello, I need the feature in the link above.

Some of the dropbox items I specified are deactivated and reactivated upon request.

But I don't know how to apply that code to my code.

Because there are some differences.

I attach my code above.

 

<input id="dropdownlist" /> <button class="k-button"> Mark Oranges as deleted</button>
    <script id="template" type="text/x-kendo-template">
    <span class="#: isDeleted ? 'k-state-disabled': ''#">
       #: name #
    </span>
    </script>

 

This is the part I don't know, and it's also where the error occurs.

 

1. I think there is no ID that can be specified because it creates input dynamically.
= <input id: dropdownlist>
(There is option.field, but it is not recognized even if it is specified as #operDay.)

1-1. As a result, you cannot access the dataSource.

2. Where should I write the <script> <span> ... </ span> </ script> section?
column? jsp?

I tried to template it in a column, but I get an "isDeleted is not defined" error. I'm thinking that I don't recognize it.

Please let me know how you can use that code ...

 

 

Ravi
Top achievements
Rank 1
 answered on 05 Mar 2021
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
Date/Time Pickers
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)
SPA
Filter
Drawing API
Drawer (Mobile)
Globalization
Gauges
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
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
OrgChart
TextBox
Effects
Accessibility
ScrollView
PivotGridV2
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
Popover
DockManager
FloatingActionButton
TaskBoard
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
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?