Page 1 of 1

PHP-Ajax Datagrid

Posted: Sat Nov 18, 2006 5:59 am
by echo19
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,
I'm currently developing a Datagrid class to easly show, sort, filter, page and edit data rows.
You can take a look to an old verison on [url]http://www.montefili.it/dev/dg.php[/url], it works only on ie..
As soon as i finish i want to post it on phpclasses.org.
Now so far the class is almost complete, but I was wondering to move it on ajax, but my skills are zero, so i have some doubts about it but my main question is on the page structure.
Actually its something like that:
>>User.php

Code: Select all

<HTML>
<?
require_once("DataGrid_class.php");
$dg=new DataGrid();
//$dg->Settings
?>
<?$dg->Render();?>
</HTML>

But in ajax i need a page that know all the settings but doesnt have the user grafical interface, so can reply to requests without rendering each time the unwanted html.
I can found only two ways of doing that:

a)Use a kind of configuration file (here dg.php) that replies to ajax requests, something like:

>>User.php

Code: Select all

<HTML>
<?
require_once("dg.php");
?>
<?$dg->Render();?>(Ajax requests to dg.php)
</HTML>

>>dg.php

Code: Select all

<?
require_once("DataGrid_class.php");
$dg=new DataGrid();
//$dg->Settings
$dg->Done();
?>
]


b)Use sessions for settings:

>>User.php

Code: Select all

<HTML>
<?
require_once("DataGrid_class.php");
$dg=new DataGrid();
//$dg->Settings
?>
<?$dg->Render();?>(Ajax requests directly to Datagrid_class.php?datagrid_name, settings stored in session [$datagrid_name])
</HTML>
Using session have a major drawback: i cant easly use callback funtion and user defined procedure..
I almost dislike both, do you have a better idea? or what do you think is the best?


Thank you for your help


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Slighty OT - class enhancement request

Posted: Mon Nov 20, 2006 5:14 am
by obiron
Sorry for being OT but one thing I find is always missing is the ability to sort on more than one column. In the example web site given, it would be useful to be able to sort by Say - Categoria Ascending and then Username Descending.

I'm not sure how you would prepare the user interface for deciding the sort priority or number of levels of sort allowed.

As for your problem I would suggest that as well as the grid, the class sends back the config data as a DIV with visible = false. This way you can store the select and config data directly in the web page and use a javascript function to navigate the DOM and extract the values that you need from the hidden DIV when you need to resubmit.


Aaron