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

Kendo Grid Datasource

2 Answers 272 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35) asked on 16 Feb 2012, 12:10 PM
Hi Everybody,

     I am trying to bind the kendoui grid using a method on my code behind page (i.e c# page)

    My aspx page content is like beow:

    In the below code block the portion that is marked in bold is the place were we specify data source for the grid.
    My doubt is, how do i bind this grid by calling a method (that return a json or string) in my code behind page,
    without using webservices.

   how do i specify a c# method as datasource, and what possible values can that function return.

<div id="example" class="k-content">
        <div id="grid">
        </div>
        <script>
               
                $(document).ready(function() {
                    $("#grid").kendoGrid({
                        dataSource: {
                            
                            transport: {
                                read: { url:"testgrid.aspx/LoadData",            
                                    dataType: "string"}

                            },
                            schema: {
                                model: {
                                    fields: {
                                        Age: { type: "number" },                                        
                                        Name: { type: "string" }
                                    }
                                }
                            },
                            pageSize: 10,
                            serverPaging: true,
                            serverFiltering: true,
                            serverSorting: true
                        },
                        height: 250,
                        filterable: true,
                        sortable: true,
                        pageable: true,
                        columns: [{
                                field:"Age",
                                filterable: false
                            },
                            
                            "Name"
                        ]
                    });
                });
            </script>
    </div>
Any one please give a suggestion to bind the kendo grid using code behind(c#) methods.

I am using visual studio 2008 and .net framework 3.5.

Thank You,

2 Answers, 1 is accepted

Sort by
0
bahareh
Top achievements
Rank 1
answered on 24 Feb 2012, 06:45 PM
.
0
Bahar
Top achievements
Rank 1
answered on 26 Feb 2012, 01:24 PM
 I Also Need This,plz help how can I do this?
I Also try this code but No data populate in Grid,
<div id="example" class="k-content">
            <div id="grid"></div>
    <script>
       
        function GetArtists() {
            var _resData;
       $.ajax({
             type: 'GET',
             url: 'http://www.letsdokaraoke.com/api/Artists?format=json',
             dataType: 'json',
             success: function(data) {
             _resData = data.artists;
             },
             data: {},
             async: false
        });

         return _resData;
     }
     
     
var artistSource2 = new kendo.data.DataSource({
    data: GetArtists(),
    schema: {
        model: {
        fields: { ID: { type: "number" },
        Name: { type: "string" },
        Gender: { type: "string" },
        Category: { type: "string" }
            }
        }
    }
});

 $("#grid").kendoGrid({

        dataSource: artistSource2,
    
            height: 600,
           scrollable: true,
            sortable: true,
            filterable: false,
            pageable: true,
            columns: [
       { field: "ID" },
       { field: "Name" },
       { field: "Gender" },
       { field: "Category"}],
    pageable: true

});
 </script>
 
 
 
 
</div>


Plz Answre me.as soon as posible,thanks.
Tags
Grid
Asked by
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Answers by
bahareh
Top achievements
Rank 1
Bahar
Top achievements
Rank 1
Share this question
or