This is a migrated thread and some comments may be shown as answers.

[Solved] How to invoke datasource read of kendo dropdownlist within grid from its own cascade event

1 Answer 208 Views
Grid
This is a migrated thread and some comments may be shown as answers.
moonolite
Top achievements
Rank 1
moonolite asked on 24 Nov 2014, 02:07 PM
I am using kendo HTML v2013.1.226 and I have a dropdownlist inside the grid.I need to invoke datasource read method for that dropdown from the cascade event of the same dropdown.Is it possible using 'this' keyword.A sample code works well in Kendo Dojo test page but same code gives this error in my application on eclipse.In this example catogary field is the dropdown. "Uncaught TypeError: Cannot read property 'data' of undefined kendo.all.min.js:11" Any suggestion.I am using kendo HTML v2013.1.226 and I need to stick with this version and cant update to new version :(.Thanks in Advance

<!DOCTYPE html>
<html>
<head>
<style>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
 
</head>
<body>
        <script src="../content/shared/js/products.js"></script>
     <div id="example">
        <div id="grid"></div>
 
        <script>
 
          var url;
            $(document).ready(function () {
 
                var dataSource = new kendo.data.DataSource({
                   pageSize: 5,
                   data: products,
                   autoSync: true,
                   schema: {
                       model: {
                         id: "ProductID",
                         fields: {
                            ProductID: { editable: false, nullable: true },
                            ProductName: { validation: { required: true } },
                            Category: { defaultValue: { CategoryID: 1, CategoryName: "Beverages"} },
                            UnitPrice: { type: "number", validation: { required: true, min: 1} }
                         }
                       }
                   }
                });
 
                $("#grid").kendoGrid({
                    dataSource: dataSource,
                    pageable: true,
                    height: 350,
                    toolbar: ["create"],
                    columns: [
                        { field:"ProductName",title:"Product Name" },
                        { field: "Category", title: "Category", width: "180px", editor: categoryDropDownEditor, template: "#=Category.CategoryName#" },
                        { field: "UnitPrice", title:"Unit Price", format: "{0:c}", width: "130px" },
                        { command: "destroy", title: " ", width: "150px" }],
                    editable: true
                });
            });
 
 
         function onSelect(e) {
           // console.log("DDD");
 
                };
 
 
 
            function categoryDropDownEditor(container, options) {
                $('<input id="catId" required data-text-field="CategoryName" data-value-field="CategoryID" data-bind="value:' + options.field + '"/>')
                    .appendTo(container)
                    .kendoDropDownList({
                        autoBind: false,
                  cascade:function(e){        
                   // onSelect(options.model)
                            var g=JSON.stringify(options.model);
                    var p1=options.model;
                            console.log("HIFF"+g);
                            alert("new server request Made with parameter1 = "+p1["QuantityPerUnit"]+" and parameter2 = "+p1["ProductName"]);  
//the next line shows ERROR in my Application                              
           $("#catId").data("kendoDropDownList").dataSource.read({eer:p1["QuantityPerUnit"],rrf:p1["ProductName"]});
 
                    },
                        dataSource: {
                            type: "odata",
                            transport: {
                                read: url1
                            }
                        }
                    });
            }
 
        </script>
    </div>

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 26 Nov 2014, 01:29 PM
Hello,

I am afraid that is not very clear what is causing the depicted error. Could you provide a repro Dojo demo? This will help to review the implementation in action and advice you further.

As a side note, I would suggest you try the latest official release of Kendo UI as the purpose of the trial downloads is to evaluate the product and its future value for your project. 

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
moonolite
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or