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

grid remote data json

3 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Seaman
Top achievements
Rank 1
Seaman asked on 03 Mar 2012, 12:59 PM
hi all;
im use grid for remote jsp return json data,for example:
[{title: "Star Wars: A New Hope", year: 1977}, {title: "Star Wars: The Empire Strikes Back", year: 1980}]
grid 
<script type="text/javascript" >
    $(document).ready(function(){
        var sharableDataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url:"contract/test.jsp",
                    dataType: "json"
                }
            }
        });
        $("#grid").kendoGrid({
            dataSource: sharableDataSource,
            columns: [
                { title: "title", field: "title", width: 130},
                { title: "year", field: "year",width: 100},],
            height: 550,
            groupable: false,
            scrollable: true,
            sortable: true,
            pageable: true
        });
    });
</script>
but grid empty,no any,pls help me ,thanks.

3 Answers, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 21 Mar 2012, 02:13 PM
I am having the exact same problem. 

Though sometimes it populates the grid, ...and sometime by doing a minor change (added a sortable: true) it works.
Suddenly it stops to work again without no obvious reason.

Checking the DOM the content is present, it seems that it's invisible due to element height.
Setting this explicitly the content is shown in the grid.

There seems to be an issue with grid autosize as default.
0
Jeremy
Top achievements
Rank 1
answered on 21 Mar 2012, 08:42 PM
I am having a similar problem. Has anyone figured this out?
0
Jeremy
Top achievements
Rank 1
answered on 21 Mar 2012, 09:04 PM
I finally figured this out. I'm using PHP on the server and thanks to an old post by Remy Sharp I changed my code from:

echo json_encode($data);

to 

echo $_GET['callback'].'('.json_encode($data).');';

and this fixed it for me.

Tags
Grid
Asked by
Seaman
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
Share this question
or