Telerik Forums
Kendo UI for jQuery Forum
3 answers
1.0K+ views

Hi,

 

I've been able to make drag&drop between two listview, but the dropped elements always go at the end of stack.

I'd like to position the dropped elements exactly where they are dropped, among the others, and then keep them sortable inside the listview.

Something like this: http://www.jqueryrain.com/?cy_emSfj

 

Currently my code is the following, but I'm not able to manage the position drop and sorting:

 

<div id="listA"></div>
<div id="listB"></div>
 
<script type="text/x-kendo-tmpl" id="template">
    <div class="bitem">
        Name: #: item # (#: position #)
        <a class="k-button k-button-icontext k-delete-button" id="delete_user"  href="javascript:delusr(this)"><span class="k-icon k-delete"></span>X</a>
    </div>
</script>
 
 
<script>
    //create dataSource
    var listA_DS = new kendo.data.DataSource({
        data: [
            { id: 1, item: "Label", position:0 },
            { id: 2, item: "Text", position: 0 },
            { id: 3, item: "Radio", position: 0 },
            { id: 4, item: "DropDown", position: 0 },
            { id: 5, item: "CheckBox", position: 0 }
        ],
        schema: {
            model: {
                id: "id",
                fields: {
                    id: { type: "number" },
                    item: { type: "string" },
                    position: { type: "number" }
                }
            }
        }
    });
 
    //display dataSource's data through ListView
    $("#listA").kendoListView({
        dataSource: listA_DS,
        template: "<div class='item'>Name: #: item #</div>"
    });
 
 
    //create a draggable for the parent container
    $("#listA").kendoDraggable({
        filter: ".item", //specify which items will be draggable
        dragstart: function (e) {
            var draggedElement = e.currentTarget, //get the DOM element that is being dragged
                dataItem = listA_DS.getByUid(draggedElement.data("uid")); //get corresponding dataItem from the DataSource instance
 
            console.log(dataItem);
        },
        hint: function (element) { //create a UI hint, the `element` argument is the dragged item
            return element.clone().css({
                "opacity": 0.6,
                "background-color": "#0cf"
            });
        }
    });
 
    var listB_DS = new kendo.data.DataSource({
        data: [ /* still no data */],
        schema: {
            model: {
                id: "id",
                fields: {
                    id: { type: "number" },
                    position: { type: "number" },
                    item: { type: "string" }
                }
            }
        }
    });
    $("#listB").kendoListView({
        dataSource: listB_DS,
        //template: "<div class='item'>ListB: #: item #</div>"
        template: kendo.template($("#template").html())
    });
 
    function addStyling(e) {
        this.element.css({
            "border-color": "#F00",
            "background-color": "#e0e0e0",
            "opacity": 0.6
        });
    }
 
    function resetStyling(e) {
        this.element.css({
            "border-color": "black",
            "background-color": "transparent",
            "opacity": 1
        });
    }
 
    var dest;
    $("#listB").kendoDropTarget({
        dragenter: addStyling, //add visual indication
        dragleave: resetStyling, //remove the visual indication
        drop: function (e) { //apply changes to the data after an item is dropped
            var draggableElement = e.draggable.currentTarget,
            dataItem = listA_DS.getByUid(draggableElement.data("uid")); //find the corresponding dataItem by uid
 
            dataItem.item = "ListB";
            dest = $(e.target);
            if (dest.get("id")) {
                //reorder the items
                var tmp = target.get("position");
                target.set("position", dest.get("position"));
                dest.set("position", tmp);
 
                listB_DS.sort({ field: "position", dir: "asc" });
            }
            else {
 
            }
 
            //listA_DS.remove(dataItem); //remove the item from ListA
            listB_DS.add(dataItem); //add the item to ListB
            $("#listB").height("+=60");
            resetStyling.call(this); //reset visual dropTarget indication that was added on dragenter
        }
    });
 
     
    function delusr(elem) {
        var item = $(elem).closest("[role='option']");
        var data = listB_DS.getByUid(item.data("uid"));
        alert(item);
    }
 
</script>
 
<style>
    #listA, #listB {
        width: 300px;
        height: 280px;
        float: left;
        margin-right: 30px;
        border: 3px solid black;
        border-radius: 3px;
    }
 
    .item, .bitem {
        margin: 5px;
        padding: 5px;
        text-align: center;
        border: 2px solid #ccc;
        border-radius: 5px;
        width:260px;
    }
</style>

Genady Sergeev
Telerik team
 answered on 01 May 2015
2 answers
267 views

I updated my site to the latest Kendo Release 2015.1.429 from the previous update and now I am getting a "Too much recursion error" when data binding.

<script type="text/x-kendo-template" id="filtering-template">
    <div>
        <h3 data-bind="text: data.filter.Name"></h3>
        <table class="edit-panel">
            <colgroup>
                <col class="fields-col">
                <col class="operator-col">
                <col class="value-col">
                <col class="required-col">
                <col class="delete-col">
            </colgroup>
            <tbody data-template="filtering-row-template" data-bind="source: data.filter.Rows"></tbody>
        </table>
        <div id="filter-commands">
            <a id="filter-search" data-role="button" data-bind="click: search" data-sprite-css-class="k-icon custom-icon search-icon">Search</a>
            <a id="filter-clear" data-role="button" data-bind="click: clear" data-sprite-css-class="k-icon custom-icon clear-icon">Clear</a>
            <a id="filter-add-row" data-role="button" data-bind="click: addRow" data-sprite-css-class="k-icon custom-icon add-icon">Add</a>
            <a id="filter-save" data-role="button" data-bind="click: saveFilter" data-sprite-css-class="k-icon custom-icon save-icon">Save</a>
            <a id="filter-saveas" data-role="button" data-bind="click: saveAsFilter" data-sprite-css-class="k-icon custom-icon saveas-icon">Save As</a>
            <a id="filter-delete" data-role="button" data-bind="click: deleteFilter" data-sprite-css-class="k-icon custom-icon delete-icon">Delete</a>
        </div>
        <div id="filter-status" class="k-block">Hello</div>
    </div>
</script>


<script type="text/x-kendo-template" id="filtering-row-template">
    <tr>
        <td><input class="field" data-role="dropdownlist" data-text-field="Name" data-value-field="ID"
               data-bind="source: fields, value: Field, events: {change: fieldChanged}" /></td>
        <td><input class="operator" data-role="dropdownlist" data-text-field="Text" data-value-field="Value"
               data-bind="source: operators, value: Operator" data-value-primitive="true" /></td>
        <td><input class="value k-textbox" data-bind="value: Value" data-abs="true" /></td>
        <td>
            <input type="checkbox" data-bind="checked: Required" /> Req
        </td>
        <td>
            <a class="remove k-button k-button-icon" data-bind="events: {click: removeRow}"><span class="k-icon k-i-close">Delete</span></a>
        </td>
    </tr>
</script>

if I comment out the dropdownlist's in the "filtering-row-template" template the error stops.

 

Wayne Hiller
Top achievements
Rank 1
Veteran
Iron
 answered on 01 May 2015
1 answer
105 views
I have a problem changing the words ”Week”, ”Month”, ”Today”, ”All day” and “Show business hours” to danish in my scheduler. A part from that, the translation works very well.

I get the following console errors, when I load the kendo.messages.da-DK.min.js:

:9 Uncaught TypeError: Cannot read property 'FilterCell' of undefined

Furthermore I get the following error, when I load the kendo.timezones.min.js:

:9 Uncaught TypeError: Cannot set property 'zones' of undefined

I’m using the following code ripped from one of your examples:

$("#scheduler").kendoScheduler({
          date: Date.now(),
          views: [
           "week", // a view configuration can be a string (the view type) or an object (the view configuration)
           { type: "week", selected: true }, // the "week" view will appear as initially selected
           "month"
          ],
          timezone: "Etc/UTC",
          dataSource: content,
          editable: false,
          currentTimeMarker: false,
      });

Please advise me to change the word stated above as well as correct the console errors.
Bozhidar
Telerik team
 answered on 01 May 2015
2 answers
338 views

Are there any examples doing drag and drop from a grid control to the scheduler in Angular?  I have found the jQuery example, but for the life of me can't get it to work correctly with the angular directives.  Right now I am using a combination of jQuery and angular, which is both terrible to look at, and causing problems since my templates cannot use Angular controls. 

The parts I am unsure of how to do in Angular are:

 

var grid = $("#grid").data("kendoGrid");
           var gridRowOffset = grid.tbody.find("tr:first").offset();
 
 
           grid.table.kendoDraggable({
               filter: "tbody > tr",
               dragstart: function (e) {
                   //add margin to position correctly the tooltip under the pointer
                   console.log('drag start');
                   console.log(gridRowOffset);
                   $("#dragTooltip").css("margin-left", e.clientX - gridRowOffset.left - 50);
               },

 Essentially if I could get the demo from http://www.telerik.com/support/code-library/drag-and-drop-17b3dbbc367a 

to work in Angular, I could figure the rest out from there!

T. Tsonev
Telerik team
 answered on 01 May 2015
2 answers
268 views

var dataSource = new kendo.data.DataSource({

    transport: {

        read: {

            url: "/GetData",

            dataType: "json"

        }

    },

    group: {

        field: "Name",

        dir: "asc"

    }

});

dataSource.read();

var view = dataSource.view();

 Using Fiddler, I can see that the call to dataSource.read() is successfully getting the JSON. However, dataSource.view() always returns an empty array. I'm not sure why this is the case.

 The JSON I'm returning looks like this:

 

[

     {
      "Name": "Bob",
      "Count": 2762,
      "Date": "2011-11-14 09:00"
    },
    {
      "Name": "Sue",
      "Count": 521,
      "Date": "2011-11-14 09:00"
    },
    {
      "Name": "Bob",
      "Count": 2769,
      "Date": "2011-11-15 09:00"
    },
    {
      "Name": "Sue",
      "Count": 525,
      "Date": "2011-11-14 09:00"
    }

]

Iliana Dyankova
Telerik team
 answered on 01 May 2015
1 answer
303 views

We are exporting Kendo grid content to Excel files. We’re really impressed with how well it works and how easy it is to use. Unfortunately, it is missing one feature that is critical for us. We need to be able to set cell comments in the exported Excel file. I posted the “idea” below to the Telerik site. I think this would only be a few lines of code for Telerik to implement. Our schedule is really tight – we’d really appreciate any help we can get - even if it is just guidance on how we could hack Kendo JavaScript to make it work (as a short-term solution).

This is the 'idea' that I posted: Add support for exporting cell comments to Excel

I'm going to explain this in a number of different ways just to help clarify what I'm asking for: 1) When exporting Kendo grid to Excel, add support for setting the cell comments. 2) Please add support for a "comment" property to sheets.rows.cells. The value of the "comment" property would be used to set the cell comment in the generated Excel file. 3) In the link below, there is support for sheets.rows.cells.format. Add a similar property named sheets.rows.cells.comment that is used to set the cell comment in the exported Excel file. http://docs.telerik.com/kendo-ui/api/javascript/ooxml/workbook.html

T. Tsonev
Telerik team
 answered on 01 May 2015
1 answer
175 views

I have an Editor Template popup for Edit functionality in my Grid. I have a combination of controls on the popup including numeric text box, dropdown and plain text boxes. If I edit information on the work, sometimes the Edit action method in my Controller is not being fired. I noticed that the only time it hits the method when a change to dropdown list happens. For any other update, the method does not get fired.

It seems like the only time the edit state gets changed when a change in dropdown list option happens.

Has anyone else noticed this behavior?

Alexander Popov
Telerik team
 answered on 01 May 2015
2 answers
175 views

I'm trying to use a treelist to display some local data until I'm ready to submit it to the server.  Since it starts empty and it'll only be submitting later, which I'll be doing with a different bit of javascript, I don't have any ajax calls back to the server.  I just want it using local data.  I built the following example using your demo dojo.  

 

<!DOCTYPE html>
<html>
<head>
    <style>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</style>
    <title></title>
 
</head>
<body>
        <div id="example">
            <div id="treelist"></div>
          <button id="btnClick" onclick="clickMe()">Click Me</button>
            <script>
                $(document).ready(function () {
                    var dataSource = new kendo.data.TreeListDataSource({
                        schema: {
                            model: {
                                id: "id",
                                expanded: true
                            }
                        }
                    });
 
                    $("#treelist").kendoTreeList({
                        dataSource: dataSource,
                        editable: true,
                        height: 540,
                        columns: [
                            { field: "Position" },
                            { field: "Name" },
                            { command: [ "edit" ] }
                        ]
                    });
                });
               
              function clickMe(){
                 
               $("#treelist").data("kendoTreeList").dataSource.add(
                 {
                   id: 123232,
                   parentId: null,
                   Position: "CEO",
                   Name: "Jeff Bezos"
                 });
              }
            </script>
        </div>
 
 
</body>
</html>

As you can see, it's a pretty simple example where I click a button to add a row to the treelist's datasource and the new row adds just fine.  The problem is when I try to edit the row after adding it.  When I click "Update" it just removes the row instead of saving the changes.  

Please advise.  

Alexander Popov
Telerik team
 answered on 01 May 2015
2 answers
154 views

Hi

I've got an issue with a lockable action columns in a grid where by some data isn't displaying.

Here is an example of the issue

http://dojo.telerik.com/oToFe

If you scroll to the end of the grid you'll notice some of the edit bars are missing - if you resize a column then they will appear - it seems that the height of the locked column isn't calculating correctly.

If you make the pageSize in the dataSource bigger the issue becomes worse (from 10 to 20 in this case)

http://dojo.telerik.com/oToFe/3

Any thoughts on a fix ?

Thanks

Dave

Dave
Top achievements
Rank 1
 answered on 01 May 2015
1 answer
102 views
As i am new to KendoUI,and i am trying some controls which i can use.When using Dropdownlist,i am not able to select the items through mouse,however the slection is happenning through keyboard.I saw the question in another post,but there is no answer.Pls help.
Peter Filipov
Telerik team
 answered on 01 May 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
Drag and Drop
Map
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
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?