Telerik Forums
Kendo UI for jQuery Forum
2 answers
186 views

Hi,

      I have two treeview widget (source and target treeview), when I check any sub-node from Optional root node of the source treeview (this treeview has three root levels -Optional, Mandatory and All- within are its corresponding sub-nodes ) I want copy the sub-node to the corresponding root node of the target treeview, for that I'm doing this:

 <script>

 function onCheckCopyNode(sourceTreeView, targetTreeView)   
    {
        sourceTreeView.dataSource.bind('change', function (e) {
            var sourceNodes = sourceTreeView.dataSource.view();
            var targetNode = targetTreeView.findByText('Optional');
             for (var i = 0; i < sourceNodes.length; i++) {
                var sourceChildren = sourceNodes[i].children.view();
                if (sourceChildren) {
                    for(var j = 0; j < sourceChildren.length; j++){
                        if((typeof sourceChildren[j].checked!==undefined)&&(sourceChildren[j].checked)){
                            targetTreeView.append(sourceChildren[j], targetNode);
                        } else  if((typeof sourceChildren[j].checked!==undefined)&&(sourceChildren[j].checked)){

                                        var element = targetTreeView.findByUid(children[i].uid);
                                        targetTreeView.remove(element);

                            }

                    }
                }
            }

        });

    }

 

function KendoHierarchicalDataSource(element, data, textFields, checkBoxOption, dragAndDropOption, onLoadCopyNode) {

    element.kendoTreeView({
        checkboxes: {
            template: "<input type='checkbox' #= (item.Selectable === false) ? 'disabled' : '' #>", //#= item.Selectable ? 'checked' : '' #
            checkChildren: checkBoxOption
        },
        dragAndDrop: dragAndDropOption,
        dataSource: data,
        dataTextField: textFields
    });
}

     $(document).ready(function () {
        KendoHierarchicalDataSource($('#s-field-treeview'), [{ MandatoryId: 1, MandatoryName: 'Optional' }, { MandatoryId: 2, Selectable : false, MandatoryName: 'Mandatory' }], ['MandatoryName', 'FieldName'], true, true, null);
        KendoHierarchicalDataSource($('#a-field-treeview'),@Html.Raw(Json.Encode(@ViewBag.fields.Data)), ['MandatoryName', 'FieldName'], true, true, onLoadCopyNode);
        onCheckCopyNode($('#a-field-treeview').data('kendoTreeView'), $('#s-field-treeview').data('kendoTreeView'));
    });

</script>

 

The code above inserts the checked sub-node to the corresponding root node of the target treeview; this is removed when I uncheck the source sub-node, the troubles comes when I try it add again because the target treeview doesn't refresh, then I need check another source sub-node for the change event to be fired

 

 

 

 

 

Alex Gyoshev
Telerik team
 answered on 10 Jun 2016
4 answers
1.0K+ views
Hi,
     As I mentioned I want to add "Add New Record " toolbar or button which adds a new row in grouped sections of Kendo grid, I have grouped items as individual sections in kendo grid as below 

$(function () {
var data1 = [{ ProgramName: "testing", Businesssegment: "test", deliveryQuater: "FY10" }, { ProgramName: "testing", Businesssegment: "test2", deliveryQuater: "FY11" },
{ ProgramName: "testing1", Businesssegment: "test3", deliveryQuater: "FY10" }, { ProgramName: "testing1", Businesssegment: "test4", deliveryQuater: "FY11" },
{ ProgramName: "testing2", Businesssegment: "test3", deliveryQuater: "FY10" }, { ProgramName: "testing2", Businesssegment: "test4", deliveryQuater: "FY11" }];


$("#body").kendoGrid({
dataSource: {
data: data1,
group: { field: "ProgramName" }


},
resizable: true,
columns: [
{
title: "Friendly Name", field: "Businesssegment", width: 50
},
{
title: "Url", field: "deliveryQuater", width: 50
},

{ command: ["edit", "destroy"], title: "&nbsp;", width: "172px" },


],
editable: "inline",
toolbar:["create"],
scrollable:true,
height: 820
});



});

When I add toolbar:["create"] property it adds as toolbar at the top of the grid but I need the same for each section which is grouped in the grid.

 Attached the current grid after implementing above code and expected grids ,Please help how to achieve the expected grid.Please ignore template.png
Vladimir Iliev
Telerik team
 answered on 10 Jun 2016
1 answer
591 views

I test simple chart example with below data. it contains one DATE typed data and two NUMBER typed data. actually I make a chart with DATE category and NUMBER value :

<DATA :  data_small.json>
[
  {
    "START_DATE": "2011-11-02T00:00:00",
    "USE_PERCENTAGE": 38,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 32400
  },
  {
    "START_DATE": "2011-11-03T00:00:00",
    "USE_PERCENTAGE": 75,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 64800
  },
  {
    "START_DATE": "2011-11-04T00:00:00",
    "USE_PERCENTAGE": 71,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 61200
  },
  {
    "START_DATE": "2011-11-05T00:00:00",
    "USE_PERCENTAGE": 72,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 0
  },
  {
    "START_DATE": "2011-11-10T00:00:00",
    "USE_PERCENTAGE": 60,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 0
  },
  {
    "START_DATE": "2011-11-15T00:00:00",
    "USE_PERCENTAGE": 90,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 77400
  },
  {
    "START_DATE": "2011-11-20T00:00:00",
    "USE_PERCENTAGE": 61,
    "RESOURCE_ID": "RS_ASSEMBLER",
    "USE_TIME": 52200
  },
  {
    "START_DATE": "2011-11-02T00:00:00",
    "USE_PERCENTAGE": 49,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 0
  },
  {
    "START_DATE": "2011-11-03T00:00:00",
    "USE_PERCENTAGE": 24,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 20400
  },
  {
    "START_DATE": "2011-11-04T00:00:00",
    "USE_PERCENTAGE": 18,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 15000
  },
  {
    "START_DATE": "2011-11-05T00:00:00",
    "USE_PERCENTAGE": 30,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 0
  },
  {
    "START_DATE": "2011-11-10T00:00:00",
    "USE_PERCENTAGE": 85,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 0
  },
  {
    "START_DATE": "2011-11-15T00:00:00",
    "USE_PERCENTAGE": 14,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 12000
  },
  {
    "START_DATE": "2011-11-20T00:00:00",
    "USE_PERCENTAGE": 18,
    "RESOURCE_ID": "RS_BOX_PACKER",
    "USE_TIME": 15000
  }

]

with codes below, I get the result like "reslut1". I didnt set categoryAxis.type. the result is : chart shows every DATE category data but without formatting it.

actually I like it. because this is matchs with my indend. but I want DATE category should be formatted.

<CODE1>

<script>
        function makeBody() {
            $.ajax({
                type: 'GET',
                dataType: 'json',
                url: './data_small.json',
                success: function (data) {
                    var chartData =  data;
                    var chart = $("#chart").data("kendoChart");
                    var chartDataSource = chart.dataSource;
                    chartDataSource.data(chartData);
                },
                error : function(a, b, c){
                    console.log("error a:" + a +" b:" + b + " c:"+ c);
                }
            });
        }
        function makeChart() {
        
            var stocksDataSource = new kendo.data.DataSource({
                group: {
                    field: "RESOURCE_ID"
                },
    
                sort: {
                    field: "START_DATE",
                    dir: "asc"
                },
    
                schema: {
                    model: {
                        fields: {
                            START_DATE: {
                                type: "date"
                            }
                        }
                    }
                }
            });
        
            function createChart() {
                $("#chart").kendoChart({
                    title: { text: "Test chart" },
                    dataSource: stocksDataSource,
                    series: [{
                        type: "line",
                        field: "USE_PERCENTAGE"
                    }],
                    legend: {
                        position: "bottom"
                    },
                    categoryAxis: {
                        field: "START_DATE",
                        crosshair: {
                            visible: true
                        },
                        // type: "date",
                        labels: {
                            rotation: "auto",
                            format: "yyyy-MM-dd" // 날짜 형식
                        }
                    }
                });
            }
            $(document).ready(createChart);
            $(document).bind("kendo:skinChange", createChart);
            
        }
        
        makeChart();
        makeBody();
        
    </script>

after this, I tried with 'type: "date",' (which is commented in above code) .(result2) I hope I get the same result with the result1 but DATE category is formatted well. but I find there are some more data than my original data. I think kendo makes some additional data with 'type=date'. am I right?

then how can I get the result like 'result1 with formatted DATE category'?

thanks in advance.

 

Iliana Dyankova
Telerik team
 answered on 10 Jun 2016
3 answers
747 views
I am trying to replicate the demo here, but using MVVM:
http://demos.kendoui.com/web/grid/toolbar-template.html

I configured the grid using data-attributes and the grid works.  The problem that I am encountering is the toolbar.

I modified the toolbar template to use the data attribute to create a kendo drop-down list:
<script type="text/x-kendo-template" id="template">
    <div class="toolbar">
        <label class="category-label" for="category">Show products by category:</label>
        <input type="search" id="category" data-role="dropdownlist" data-source="source"></input>
    </div>
</script>
In the grid declaration I added the data-toolbar attribute referencing the template:
data-toolbar='[ { template: kendo.template($("#template").html()) } ]'
However, the data attributes in the template are not being processed by Kendo UI and is rendered as-is on the page.  This resulted in a textbox rather than the drop-down list that I am expecting.

Is there a way to get this working?
Petyo
Telerik team
 answered on 10 Jun 2016
1 answer
166 views
Does anyone know of a way to turn OFF the case sensitivity on a List based validation?
Dimiter Topalov
Telerik team
 answered on 10 Jun 2016
2 answers
905 views

Hey,

I am trying to insert custom toolbar buttons (and actions) for our kendo grid. I would like to keep the existing functionality the same (i.e. the create and export to excel functions) but add additonal custom buttons by means of a toolbar template. Below is the existing code.

01.<div id="emailgroupgrid" style="height: 100%"
02.                   data-role="grid"
03.                   data-resizable="true"
04.                   data-reorderable="true"
05.                   data-sortable="true"
06.                   data-editable="popup"
07.                   data-scrollable="true"
08.                   data-toolbar="['create', 'excel']"
09.                   data-excel="{'fileName': 'file.xlsx', 'filterable': 'true'}"
10.                   data-columns="[{'field': 'firstName', 'title':'First Name', 'editable': 'true'}, {'field': 'surname', 'title':'Surname', 'editable': 'true'},{'field': 'email', 'title':'Email', 'editable': 'true'},{'command' : ['destroy', 'edit' ], 'width' : '25%'}]"
11.                   data-bind="source: users, events: {change: onGridChange}">
12.                 </div>

 

I have seen posts where the recommend hard coding the new buttons in data-toolbar parameter, and also via a template and calling

1.data-toolbar="['create', 'excel', {'template': '$(\'#toolbartemplate\').html()'}]"

1.<script id="toolbartemplate" type="text/x-kendo-template">
2.  <div id="toolbar"
3.         data-role="toolbar"
4.          data-bind="events:{click: onActionsClick}">
5.            <input type="button" class="k-button" onClick="create"/>
6.      </div>
7.  </script>

And other such variations, nothing seems to work as of yet. Everything returns either an invalid template error or simple prints out the string literal that was inputted.

As I said ideally I wouldn't have to reimplement the functionality of the existing create and excel buttons but add additional buttons with will call my own functions.

Any help would be great.

Eoin
Top achievements
Rank 1
 answered on 10 Jun 2016
2 answers
175 views

I need help returning Json data back and populating a very simple grid, here is my code:

Model:

public class CapitalLeaseCostModel
{
    public int ID { get; set; }
    public string Reasons { get; set; }
 
    public CapitalLeaseCostModel()
    {
 
    }
 
}

 

View:

<script>
    $(document).ready(function () {
         
        var crudServiceBaseUrl = "//demos.telerik.com/kendo-ui/service",
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: "/CapitalLease/Costs_Read",
                                    dataType: "json"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            },
                            batch: true,
                            pageSize: 20,
                            schema: {
                                model: {
                                    id: "ID",
                                    fields: {
                                        ID: { editable: false, nullable: true },
                                        Reasons: { type: "text" }
                                    }
                                }
                            }
                        });
 
 
        $("#capitalizedCostGrid").kendoGrid({
            dataSource: dataSource,
            pageable: true,
            height: 550,
            toolbar: ["create"],
            columns: [
                { field: "ID", title: "ID" },
                { field: "Reasons", title: "Reasons" }],
            editable: "inline"
        });
 
    });
</script>
 
@*Rent Information*@
<p class="title">Section Two - Lease Costs to Capitalize</p>
<div style="padding:15px;">
    <div id="costsRowOne">
        <div id="capitalizedCostGrid" class="inline-control"></div>
    </div>
</div>

 

Controller:

[AcceptVerbs(HttpVerbs.Get)]
        public JsonResult Costs_Read()
        {
            CapitalLeaseCostModel testModel = new CapitalLeaseCostModel();
            testModel.ID = 1;
            testModel.Reasons = "test reason1";
            List<CapitalLeaseCostModel> list = new List<CapitalLeaseCostModel>();
            list.Add(testModel);
 
            return Json(JsonConvert.SerializeObject(list), JsonRequestBehavior.AllowGet); ;
        }

 

The grid loads fine but now data. What am I missing? This is based off of the inline-editing demo for kendo-ui.

 

Thanks

 

Vi Le
Top achievements
Rank 1
 answered on 09 Jun 2016
7 answers
141 views

Hello,

Is there a way so that when I open up the filter in the grid, "Contains" will be the default in the dropdownlist? Instead of the first item in the list ?

 

Regards,

Emil

 

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 09 Jun 2016
1 answer
584 views

I seem to be having a problem posting the selected values from my Kendo Multiselect widget to an action on my controller. I've never had this issue before and as far as I know I am doing everything right, but something is obviously causing an issue.

I have this input on my view:

<input id="ProductHandlingTypes" name="ProductHandlingTypes" style="width: 100%"/>

 

Here is my viewmodel:

public class BuyerProfileViewModel
{
    public string UserId { get; set; }
    public string Name { get; set; }
    public int BuyerTypeId { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zipcode { get; set; }
    public string Description { get; set; }
    public List<int> ProductHandlingTypes { get; set; }
 
    public bool Producer { get; set; }
}

 

JavaScript:

$("#ProductHandlingTypes").kendoMultiSelect({
    placeholder: "-- Select Type(s) --",
    dataTextField: "Name",
    dataValueField: "Id",
    dataSource: new kendo.data.DataSource({
        transport: {
            read: {
                url: "/Helper/GetProductHandlingTypes",
                dataType: "json",
                type: "GET"
            }
        }
    })
});
 
$("#btnSave").on("click", function (e) {
    e.preventDefault();
    var formCreate = $(".form-register-buyer");
    formCreate.validate();
 
    if (formCreate.valid()) {
        var options = {
            url: $(formCreate).attr("action"),
            type: $(formCreate).attr("method"),
            data: $(formCreate).serialize()
        };
 
        $.ajax(options)
            .done(function(data) {
                if (data.success === true) {
                    window.location.href = data.redirectTo;
                } else {
                    toastr.options = { "postiionClass": "toast-bottom-full-width" };
                    toastr.error(data.message, "Uh, Oh!");
                }
            });
    }
});

 

And a snippit of my controller:

[HttpPost]
public ActionResult BuyerProfile(BuyerProfileViewModel model)
{
    if (ModelState.IsValid)
    {
        // do stuff here
    }
}

 

All of the rest of the values post to the controller just fine. But when I hover over the model this is what I see for "ProductHandlingTypes" (I've attached a screenshot)

 

 

Austin
Top achievements
Rank 1
 answered on 09 Jun 2016
5 answers
124 views

I'm building a mobile application using Phonegap and Kendo UI. I have 2 mobile listviews in my application, one list has only one element, and the other has about 100. I've noticed that when I tap the list with only the single item and drag down slightly, the click event on the list item won't fire, yet it still navigates to the next screen when this happens.

The template for my listview looks like this:

<script type="text/x-kendo-tmpl" id="list-template">
<div class="notice" data-​id="\#id">
<a href="\#another-page">
<div class="table-cell">
<div class="notice-list-header">
<h3 class="notice-list-date">#:start_date#</h3>
</div>
<div class="notice-list-body">
<p class="list-meta">#:title#</p>
</div>
</div>
</a>
</div>
</script>​

 

I think what's happening​ is because of the anchor tag in the template it still navigates to the page its supposed to, but because I have code in the click event to populate the page that the list item navigates to, I end up with a blank page because the click event hasn't fired.

 

I don't have this problem with the other listview that has several items, so my guess is that when a listview is scrolled kendo internally prevents the default behaviour of the list item, which in this case in an anchor tag.

 

I tried to work around this by removing the anchor from my template and then used navigate() in the click event of the list item, which does work, but when I do it this way, an extra click event is fired on the page that is navigated to so the first item on that page is automatically clicked.  

Petyo
Telerik team
 answered on 09 Jun 2016
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?