PDA

View Full Version : Using the remote dataset feature of the Grid



JC
5 Nov 2006, 4:35 PM
Hi Folks,

Does anybody know where I can download the php code for the remote dataset example ?
(http://www.jackslocum.com/yui/2006/09/26/using-the-remote-dataset-feature-of-the-grid/)

TIA,
JC

jack.slocum
5 Nov 2006, 8:02 PM
That's part of the forum2 and hasn't been released (or completed) yet. Here's what's in the file though if it's of any use. Obviously it depends heavily on my generated DataModel code but if all you are looking for is the paging logic, there it is.



<?
header('Content-Type: text/xml');

include_once("app_header.php");
include_once("classes/TopicModel.php");

$columns = array('topic_title', 'username', 'topic_replies', 'post_time', 'user2');
$page = ($_REQUEST['page'] ? $_REQUEST['page']-1 : 0);
$pageSize = $_REQUEST['pageSize'] ? $_REQUEST['pageSize'] : 50;
$sortCol = (isset($_REQUEST['sortColumn']) ? $columns[$_REQUEST['sortColumn']] : 'post_time');
$sortDir = $_REQUEST['sortDir'] ? $_REQUEST['sortDir'] : 'desc';

$forumId = $_REQUEST['forumId'];

$tm = new TopicModel($conn);

$total = $tm->getCountByForum($forumId);
$topics = $tm->findByForum($forumId, $page * $pageSize, $pageSize,
"$sortCol $sortDir" );

echo'<?xml version="1.0" encoding="UTF-8"?>';
echo '<TopicPage>';
echo '<TotalCount>'.$total.'</TotalCount>';
echo "<Topics>\n";
foreach($topics as $t){
echo "<Topic";
echo ' id="'.$t['topic_id'].'"';
echo ' forumId="'.$t['forum_id'].'"';
echo ' title="'.htmlspecialchars(utf8_encode($t['topic_title'])).'"';
echo ' type="'.$t['topic_type'].'"';
echo ' totalPosts="'.($t['topic_replies']+1).'"';
echo ' authorId="'.$t['user_id'].'"';
echo ' author="'.htmlspecialchars($t['username']).'"';
echo ' lastPost="'.date('M d Y, h:i A', $t['post_time']).'"';
echo ' lastPoster="'.htmlspecialchars($t['user2']).'"';
echo " />\n";
}
echo '</Topics>';
echo '</TopicPage>';
?>

sjivan
12 Nov 2006, 11:24 AM
Just curious why your examples are in php when you say that you're primarily a Java developer.

jack.slocum
12 Nov 2006, 7:42 PM
My host doesn't support Java.