Monday, 15 April 2013

php - Simple KendoUI Grid Not Populating -



php - Simple KendoUI Grid Not Populating -

several different questions on topic, none of answers helped, thought i'd seek , see if can figure out..

so have simple grid, here html/php:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo property_title; ?></title> <!-- load kendo css --> <link rel="stylesheet" type="text/css" href="css/kendo.bootstrap.min.css"/> <link rel="stylesheet" type="text/css" href="css/kendo.common.min.css"/> <link rel="stylesheet" type="text/css" href="css/kendo.default.min.css"/> <!-- -------------- --> <link rel="stylesheet" type="text/css" href="css/style.css" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url; ?>css/style.css" /> <script src="js/jquery.js"> // required application function </script> <!-- load kendo --> <script type="text/javascript" src="js/kendo.all.min.js"> // required application function </script> <!-- ---------- --> </head> <body class="bg"> <div class="grid-box7 box2close min_height_700" style="display: none;"> <script> // function build grid function generaterawdatagrid() { var = $("#fromdate").val(); var = $("#todate").val(); <? if ( isset($_get['source']) && is_numeric($_get['source']) ) { ?> var source = <? echo trim($_get['source']); ?>; <? } else { ?> var source = ''; <? } ?> $(".li_current_report").html("raw statistical data"); $("#rawdatagrid").kendogrid({ columns: [ { title: "action", field: "comment" } ], datasource: { transport: { read: { url: "data/get_stats.php?from=" + + "&to=" + + "&source=" + source + "&rt=3" } }, schema: { data: "data" }, type: "json" }, pageable: { refresh: true, pagesize: 15, pagesizes: [ 15,30,60,100 ] }, sortable: true, filterable: true, scrollable: false, selectable: "row", reorderable: true }); // end: study grid } // end: function generategrid() </script> <div id="rawdatagrid" > <!-- grid here --> </div> </div> </body> </html>

here datasource code:

// build sql statement $sql_stats = " select comment stats_tracking date_entered between '" . $from . "' , '" . $to . "' , action_detail1 not in(" . $excludeips . ") , active = 1"; if ( is_numeric($_get['source']) && trim($_get['source']) != "" ){ $sql_stats .= " , source = '" . $_get['source'] . "'"; } $sql_stats .= " order date_entered desc "; // info $statresult = mysql_query($sql_stats); // run actual query. $dataout = array(); // create empty array temp info store in main output array while ( $stat = mysql_fetch_object($statresult) ) { $dataout[] = $stat; } header("content-type: application/json"); echo "{\"data\":" . json_encode($dataout). "}";

the output seems fine - , lints fine well, here's piece of it:

{"data":[{"comment":"site visit"},{"comment":"site visit"},{"comment":"site visit"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"site visit"},{"comment":"view contact information"},{"comment":"site visit"},{"comment":"view contact information"},{"comment":"doctor site visit"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"doctor site visit"},{"comment":"view contact information"},{"comment":"site visit"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"view contact information"},{"comment":"doctor site visit"},{"comment":"view contact information"},{"comment":"doctor site visit"}]}

but grid isn't rendering. i've used several json validators. , browser seeing output application/json.

any ideas?

thanks in advance!

i don't see calling method. generaterawdatagrid()

perhaps need create document.ready() function , phone call there.

$(document).ready(function () { generaterawdatagrid(); });

php json kendo-ui kendo-grid

No comments:

Post a Comment