Telerik Forums
Kendo UI for jQuery Forum
2 answers
303 views
I've got a api endpoint that spits out the following JSON:

[{"Start": "2015-03-08T21:43:31Z", "Attendee": ["andrew", "bobo"], "End": "2015-03-08T22:43:33Z", "Description": "", "TaskID": 1, "Title": "Test Event", "OwnerID": 2, "IsAllDay": false}]

            schema: {
                model: {
                    id: "taskId",
                    fields: {
                        taskId: { from: "TaskID", type: "number" },
                        title: { from: "Title", defaultValue: "No title", validation: { required: true } },
                        start: { type: "date", from: "Start" },
                        end: { type: "date", from: "End" },
                        ownerId: { from: "OwnerID", defaultValue: 1 },
                        attendee: { from: "Attendee"},
                        isAllDay: { type: "boolean", from: "IsAllDay" }
                    }
                }
        },

        resources: [
            {
                field: "attendee",
                title: "Attendee",
                dataSource: [
                    { text: "Alex", value: 1, color: "#f8a398" },
                    { text: "Bob", value: 2, color: "#51a0ed" },
                    { text: "Charlie", value: 3, color: "#56ca85" }
                ]
            }
        ]
     },


All the examples I've seen for custom resources are not derived but are hard coded.  How do I get the values JSON into the dataSource resource for attendee?













Vladimir Iliev
Telerik team
 answered on 11 Mar 2015
1 answer
205 views
Hey,

I tried to implement autoSync but it throws the following exception:
:3001/js/kendo.all.min.js:11 Uncaught TypeError: Cannot read property 'call' of undefined

Here's the code of the controller that handles the grid in AngularJS.

001.define(['app'], function(app) {
002.    app.controller('MainCtrl', function ($scope, $http, $routeParams, $modal, $timeout, $q, MainService, LoginService) {
003. 
004.        /* ========================================== */
005.        /*           GENERAL INITIALIZATIONS          */
006.        /* ========================================== */
007. 
008.        // Set the culture
009.        kendo.culture("he-IL");
010. 
011.        // Define scope variables
012.        $scope.VM = {};
013.        $scope.VM.filter = {};
014.        $scope.VM.collections = {};
015. 
016.        // Define the view permissions
017.        $scope.VM.permissions = {
018.            allow_edit: true,
019.            allow_sign: true,
020.            allow_cancel: true
021.        };
022. 
023.        /* ========================================== */
024.        /*        INITIALIZING THE COLLECTIONS        */
025.        /* ========================================== */
026. 
027.        /* The list of all suppliers */
028.        $scope.VM.collections.suppliers = [
029.            {
030.                "value": "AAA",
031.                "text": "AAA"
032.            },
033.            {
034.                "value": "BBB",
035.                "text": "BBB"
036.            },
037.            {
038.                "value": "CCC",
039.                "text": "CCC"
040.            },
041.        ];
042.        /* The list of all expensesCause */
043.        $scope.VM.collections.expensesCause = [
044.            {
045.                "value":"DDD" ,
046.                "text":"DDD"
047.            },
048.            {
049.                "value": "EEE",
050.                "text": "EEE"
051.            },
052.            {
053.                "value": "FFF",
054.                "text": "FFF"
055.            },
056.        ];
057.        /* The list of all subExpensesCause */
058.        $scope.VM.collections.subExpensesCause = [
059.            {
060.                "value":"DDD" ,
061.                "text":"DDD"
062.            },
063.            {
064.                "value": "EEE",
065.                "text": "EEE"
066.            },
067.            {
068.                "value": "FFF",
069.                "text": "FFF"
070.            },
071.        ];
072. 
073.        /* ========================================== */
074.        /*      INITIALIZING THE DEFAULT FILTER       */
075.        /* ========================================== */
076. 
077.        $scope.VM.filter.from_date = moment().subtract(2, "month").toDate();
078.        $scope.VM.filter.to_date = moment().toDate();
079. 
080.        /* ========================================== */
081.        /*            INITIALIZING THE GRID           */
082.        /* ========================================== */
083. 
084.        /* Holds the list of all selected rows */
085.        $scope.VM.gridSelectedRows = [];
086. 
087.        /* The grid definition */
088.        $scope.VM.gridOptions = {
089.            height: 640,
090.            filterable: {
091.                mode: "row"
092.            },
093.            scrollable: true,
094.            sortable: true,
095.            selectable: "multiple, row",
096.            editable: true,
097.            resizable: true,
098.            reorderable: true,
099.            //groupable: true,
100.            toolbar: [
101.                { name: "excel", text: " ייצוא לאקסל" },
102.                //{ name: "save", text: "שמור"}
103.            ],
104.            excel: {
105.                fileName: "results.xlsx"
106.            },
107.            columns: [
108.                {
109.                    field: "date_created",
110.                    title: "תאריך",
111.                    template: "<div ng-bind='dataItem.date_created | date: \"dd/MM/yyyy\"' title='{{ dataItem.date_created | date: \"dd/MM/yyyy\" }}'></div>",
112.                    filterable: false
113.                },
114.                {
115.                    field: "project_name",
116.                    title: "פרויקט",
117.                    template: "<div ng-bind='dataItem.project_name' title='{{ dataItem.project_name }}'></div>",
118.                    filterable: {
119.                        cell: {
120.                            operator: "contains"
121.                        }
122.                    }
123.                },
124.                {
125.                    field: "supplier_name",
126.                    title: "מוטב",
127.                    template: "<div ng-bind='dataItem.supplier_name' title='{{ dataItem.supplier_name }}'></div>",
128.                    filterable: {
129.                        cell: {
130.                            operator: "contains"
131.                        }
132.                    },
133.                    editor: function(container, options) {
134.                        container.append(
135.                            "<select kendo-combo-box "+
136.                                "k-data-text-field=\"'text'\" "+
137.                                "k-data-value-field=\"'value'\" "+
138.                                "k-filter='contains' "+
139.                                "k-auto-bind='false' "+
140.                                "k-data-source='VM.collections.suppliers' "+
141.                                "data-bind='value:"+options.field+"'>"+
142.                            "</select>");
143.                    }
144.                },
145.                {
146.                    field: "info",
147.                    title: "פרטים" ,
148.                    template: "<div ng-bind='dataItem.info' title='{{ dataItem.info }}'></div>",
149.                    filterable: {
150.                        cell: {
151.                            operator: "contains"
152.                        }
153.                    },
154.                    width: "250px"
155.                },
156.                {
157.                    field: "expense_cause",
158.                    title: "סעיף הוצאה",
159.                    template: "<div ng-bind='dataItem.expense_cause' title='{{ dataItem.expense_cause }}'></div>",
160.                    filterable: {
161.                        cell: {
162.                            operator: "contains"
163.                        }
164.                    },
165.                    editor: function(container, options) {
166.                        container.append(
167.                            "<select kendo-combo-box "+
168.                                "k-data-text-field=\"'text'\" "+
169.                                "k-data-value-field=\"'value'\" "+
170.                                "k-filter='contains' "+
171.                                "k-auto-bind='false' "+
172.                                "k-data-source='VM.collections.expensesCause' "+
173.                                "data-bind='value:"+options.field+"'>"+
174.                            "</select>");
175.                    }
176.                },
177.                {
178.                    field: "sub_expense_cause",
179.                    title: "תת סעיף הוצאה",
180.                    template: "<div ng-bind='dataItem.sub_expense_cause' title='{{ dataItem.sub_expense_cause }}'></div>",
181.                    filterable: {
182.                        cell: {
183.                            operator: "contains"
184.                        }
185.                    },
186.                    editor: function(container, options) {
187.                        container.append(
188.                            "<select kendo-combo-box "+
189.                            "k-data-text-field=\"'text'\" "+
190.                            "k-data-value-field=\"'value'\" "+
191.                            "k-filter='contains' "+
192.                            "k-auto-bind='false' "+
193.                            "k-data-source='VM.collections.subExpensesCause' "+
194.                            "data-bind='value:"+options.field+"'>"+
195.                            "</select>");
196.                    }
197.                },
198.                {
199.                    field: "cheque_number",
200.                    title: "מספר צ'ק",
201.                    template: "<div ng-bind='dataItem.cheque_number' title='{{ dataItem.cheque_number }}'></div>",
202.                    filterable: {
203.                        cell: {
204.                            operator: "startswith"
205.                        }
206.                    }
207.                },
208.                {
209.                    field: "amount",
210.                    title: "סכום" ,
211.                    template: "<div ng-bind='dataItem.amount | currency: \"₪\"' title='{{ dataItem.amount | currency: \"₪\" }}'></div>",
212.                    format: "{0:c0}",
213.                    width: "180px"
214.                },
215.                {
216.                    field: "sig1",
217.                    title: "חתימה 1",
218.                    // TODO: need to convert date from string to actual date
219.                    template: "<div ng-bind='dataItem.sig1_user' title='{{ dataItem.sig1_signAt | date: \"dd/MM/yyyy hh:mm:ss\" }}'></div>",
220.                    filterable: false
221.                },
222.                {
223.                    field: "sig2",
224.                    title: "חתימה 2",
225.                    // TODO: need to convert date from string to actual date
226.                    template: function(dataItem) {
227.                        var template;
228. 
229.                        template += "<div ng-bind='dataItem.sig2_user' title='{{ dataItem.sig2_signAt | date: \"dd/MM/yyyy hh:mm:ss\" }}'>";
230.                        template += "</div>";
231.                    },
232.                    filterable: false
233.                },
234.                {
235.                    field: "cheque_status",
236.                    title: "סטאטוס",
237.                    template: "<div ng-bind='dataItem.cheque_status' title='#: cheque_status #'>#: cheque_status #</div>",
238.                    template: function(dataItem) {
239.                        var result = "";
240.                        var status = $scope.translationAPI.translateStatus(dataItem.cheque_status);
241.                        var css_class = dataItem.cheque_status
242. 
243.                        result += "<div title='"+status+"' class='"+css_class+"'>";
244.                        result += status;
245.                        result += "</div>";
246. 
247.                        return result;
248.                    },
249.                    filterable: {
250.                        cell: {
251.                            operator: "eq"
252.                        }
253.                    }
254.                }
255.            ],
256.            dataSource: {
257.                schema: {
258.                    model: {
259.                        fields: {
260.                            date_created: {
261.                                editable: false,
262.                                type: "date"
263.                            },
264.                            project_name: {
265.                                editable: false
266.                            },
267.                            supplier_name: {
268.                                editable: true,
269.                                validation: {
270.                                    required: true
271.                                }
272.                            },
273.                            info: {
274.                                editable: true
275.                            },
276.                            expense_cause: {
277.                                editable: true,
278.                                nullable: true
279.                            },
280.                            sub_expense_cause: {
281.                                editable: true,
282.                                nullable: true
283.                            },
284.                            cheque_number: {
285.                                editable: false
286.                            },
287.                            amount: {
288.                                editable: false
289.                            },
290.                            sig1: {
291.                                editable: false
292.                            },
293.                            sig2: {
294.                                editable: false
295.                            },
296.                            cheque_status: {
297.                                editable: false
298.                            }
299.                        }
300.                    },
301.                    data: "data"
302.                },
303.                //serverPaging: true,
304.                //serverSorting: true,
305.                //pageSize: 100,
306.                autoSync: true,
307.                transport: {
308.                    read: function(e) {
309.                        // Save the 'e' for future reference
310.                        $scope.VM.readOptions = e;
311. 
312.                        // Start the spinner
313.                        kendo.ui.progress($("div[kendo-grid]"), true);
314. 
315.                        var from_date = $scope.VM.filter.from_date;
316.                        var to_date = $scope.VM.filter.to_date;
317.                        MainService.getCheques(from_date, to_date).then(function(data) {
318.                            e.success(data);
319. 
320.                            // Stop the spinner
321.                            kendo.ui.progress($("div[kendo-grid]"), false);
322.                        });
323.                    },
324.                    update: function(e) {
325.                        // Save the 'e' for future reference
326.                        $scope.VM.updateOptions = e;
327. 
328.                        MainService.updateCheque(e.model).then(function(data) {
329.                            e.success(data);
330.                        });
331.                    }
332.                }
333.            }
334.        };
335. 
336.        /* ========================================== */
337.        /*                  Methods                   */
338.        /* ========================================== */
339. 
340.        // Check if at-least one row selected
341.        $scope.VM.isEntitySelected = function() {
342.            return $scope.VM.gridSelectedRows.length > 0;
343.        };
344.        // Check if the user is allowed to sign
345.        $scope.VM.isAllowSign = function() {
346.            return $scope.VM.permissions.allow_sign;
347.        };
348.        // Check if the user is allowed to unsign
349.        $scope.VM.isAllowUnSign = function() {
350.            return $scope.VM.permissions.allow_sign;
351.        };
352.        // Check if the user is allowed to edit existing items
353.        $scope.VM.isAllowEdit = function() {
354.            return $scope.VM.permissions.allow_edit;
355.        };
356.        // Check if the user is allowed to add new items
357.        $scope.VM.isAllowAdd = function() {
358.            return $scope.VM.permissions.allow_edit;
359.        };
360.        // Check if the user is allowed to cancel cheques
361.        $scope.VM.isAllowCancel = function() {
362.            return $scope.VM.permissions.allow_cancel;
363.        };
364. 
365.        /* Responsible for filtering the grid by the status field  */
366.        $scope.VM.changeStatus = function(e, status) {
367.            // TODO: need to implement
368.        };
369. 
370.        /* Get all cheques from within the dates range */
371.        $scope.VM.getCheques = function(e) {
372.            $scope.VM.gridOptions.dataSource.transport.read($scope.VM.readOptions);
373.        };
374. 
375.        $scope.VM.getRowsCount = function() {
376. 
377.        };
378. 
379.        $scope.VM.getAmountSum = function() {
380. 
381.        };
382. 
383.        $scope.VM.getSelectedRowsCount = function() {
384. 
385.        };
386. 
387.    });
388. 
389.});

Please advise.
Rosen
Telerik team
 answered on 11 Mar 2015
1 answer
105 views
Hello,
I have a question related to stackbar charts.

I have 2 series and dataSoursce grouping.
I'm trying to use 'StackBar style' on one of series, but I want to keep another in 'bar style'.

And I have a following problem.
Those columns are stacked. Even if I'm trying to disable second series.

Please have a look here:
http://jsfiddle.net/fyJys/712/

I need a chart that will look like something like this:
http://dojo.telerik.com/OGImU

but with first example configuration.

Is it possible?

Thanks,
Vlad.



T. Tsonev
Telerik team
 answered on 11 Mar 2015
1 answer
247 views
I have a drop-down box on a webpage that fires an event on change, that creates a grid based on the drop-down's selection.
It works fine, but after selecting a drop-down more than once, it will load the data properly but as soon as you press the page button. It will reload data from the first selection made again.
I'm assuming this has something to do with the "total" field not updating?? 
Anyway, here is my code:


<div id="select_phone" name="select_phone"/>
<div id="grid"></div>

<script>


//load a list into select_phone drop-down
$('#select_phone').load('/dashboard/select_phone.php');
            
 
  function phone_select(phone) 
  { 
// this loads the grid with data from the select_phone drop-down

$(function() {

grid=$("#grid").kendoGrid({

                         toolbar: ["excel"],
        excel: {
            allPages: true
        },
        dataSource: {
                            transport: {
                                read: "/dashboard/call_data.php?imei="+phone,
                                dataType: "json"
                            },
                            schema: {
total: function(response) 
{
                return $(response.data).length;
      },
                                data: "data"
                            },
                            pageSize: 8,
sort: {
            field: "Time",
            dir: "desc"
        }
                        },
                        height: 550,
                        scrollable: true,
resizable: true,
                        sortable: true,
                        filterable: true,
                        pageable: {
                            input: true,
                            numeric: false
                        },
                        columns: [
                            { field: "Name", title: "Name", width: "200px" },
                            { field: "Phone", title: "Phone", width: "130px" },
                            { field: "Time", title: "Call Time", width: "130px" },
                            { field: "Duration", width: "130px" }
                        ]
                    });


});

$('#grid').data('kendoGrid').refresh();

  }
 
 </script>
Jay
Top achievements
Rank 1
 answered on 11 Mar 2015
2 answers
307 views
I would love it if the drop down list could show a list of items with sub-menus such as the products menu shown at: http://demos.telerik.com/kendo-ui/menu/index

I'm trying to hack together a solution using the menu control, but it isn't trivial to do (especially when AngularJS is involved). Is something like this possible already?
Brian Vallelunga
Top achievements
Rank 1
 answered on 11 Mar 2015
1 answer
585 views
Hey,

I'm trying to accomplish the following scenario for setting filter dynamically from outside the grid:
I have a 'Status' column, I want to set the filter for this column to 'Pending' by clicking a 'Pending' button which is located outside the grid.

Please advise.
Kiril Nikolov
Telerik team
 answered on 10 Mar 2015
1 answer
265 views
I am having trouble with styling my custom group footer templates. You can see in the screen shot that I have two footers and they are both indented at the same level. This is misleading and hard to understand. 

There are two things that could potentially make this easier to read but I can't seem to find a way to accomplish either one. 

1. Find a way to put the associated group name in the footer
2. Style or remove the spacer td elements so that each footer appears to align with it's parent group header.

This would be fairly easy to fix if the grid would add some sort of identifiable attribute/class/id to these footers so that they could easily be targeted, but I see no such thing. 

Any help or suggestions would be appreciated?
Petur Subev
Telerik team
 answered on 10 Mar 2015
2 answers
109 views
There is a bug in Kendo UI GridView when running on chrome version 41.0.2272.76. Is there a bug fixing for this error?

I'll appreciate any help.
J.
Top achievements
Rank 1
 answered on 10 Mar 2015
4 answers
307 views
Hi!
I started using the new filter row and I think it's great!
However, in busy grids with several columns it looks awful. The filter controls don't resize, so in narrow columns it get's cut off and in wide columns the space is wasted.

I created a helper function that through some event handlers, attempts to fix this. All you need to do is call "grid.autoFixFilterWidth()"

http://jsbin.com/wipazupexaqi/3/edit


I really wish something like this would be implemented by default, hopefully using css rules and not some hacky js like my solution, but in the mean time this works for me. Ymmv.
Hope it helps someone!
Regards

Andrés
Alexander Popov
Telerik team
 answered on 10 Mar 2015
2 answers
477 views
I'm sure I'm missing something simple here, but I am trying to develop a site for a British based group and I'm trying to display a set of values in GBP. I have included the culture file and when I display currency, I see Â£20.00. I've spent some time looking and people are are saying that the character encoding is set wrong, changing it to UTF-8 does nothing. I tried to modify the culture file to include &pound; instead of the actual symbol placed in there, but it's encoding that so I get &pound; put on the page.
Terry Burns-Dyson
Top achievements
Rank 1
 answered on 10 Mar 2015
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
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?