Posted by Jerome (Guest)
on 16.04.2006 09:22
For php beginners who want an example and little tutorial, i tried to
 write one...
You can check at :
http://jerome.sadou.free.fr/grid

Jerome
Posted by Ken Gregg
on 16.04.2006 17:14
Jerome,

Good job. I did notice that in the following lines in xml_maker.php, the 
second $xml = should be $xml .=

//Let's write the xml format required by rico
$xml = '<'.'?xml version="1.0" encoding="ISO-8859-1"?'.'>';
$xml = '<ajax-response><response type="object" 
id="data_grid_updater"><rows
update_ui="true">';

Firefox at least doesn't seem to care.

Let us know if you are going to work on extending that to include 
options and parameters. I was going to do this next but won't bother if 
you are.

Ken
Posted by Jerome (Guest)
on 16.04.2006 18:31
hi thanx for your notice...it s my mistake...yeah next step is to add 
"sorting"
by columns...i ll try to post it next week... i am quite busy...

Jerome
Posted by clint (Guest)
on 20.04.2006 00:32
Jerome,

 I just wanted to give you a big thanks! I will be using something 
similar to this now that you have helped me!

Thanks man! :-)
Posted by tobi (Guest)
on 21.04.2006 12:58
Me too! Thanks! It was a really big help.

.t
Posted by Rebecca (Guest)
on 21.04.2006 19:27
Yea, you totally rock!  This was perfect for getting me started.

Sorting and query parameters would be a welcome addition, if and when 
you get around to it :)

Thanks again!
Rebecca
Posted by Myra (Guest)
on 24.04.2006 07:52
Hi,
Could you tell me please if we have an exemple for a script for a table 
like the one in LiveGrid, but dynamiquely uploaded from a database in 
form of views
with pagination for exemple, each view is uploaded from the database 
when we want
to display it. (instead uploading by the scroll, we upload by a 
pagination).

Thank you
Posted by Ken (Guest)
on 24.04.2006 14:10
I am not sure what you mean by views. If you mean different data columns 
with dofferent filters applied then it is a mater of clearing the grid 
and reloading your new data. I am currently using an iframe to contain 
my grids to make this easier.
Posted by Zin (Guest)
on 24.04.2006 20:44
Does anyone try to use requestParameters option???

Ex:
var params = "city=Lodon";
var opts = { prefetchBuffer: true, requestParameters: params}
new Rico.LiveGrid ('data_grid', 5, 10, 'searchresult.php',
opts);

is it possible to do that? Can someone help me to write a function that 
when I click on a button, the javascript function will be called (as the 
Rico Yahoo search example), I tried it already but each time I click, 
the new scrollbar display ???
Posted by padz (Guest)
on 26.04.2006 07:15
hi....

i wonder why there is no scrollbars when i ran the script in the 
tutorial??
can you help me??
Posted by Werner xxxxx
on 27.04.2006 10:54
Nice example, looking forward too more examples and documentation
Posted by Jérôme
on 13.05.2006 13:43
I just updated my example for sorting choosing a column
(with little help from Chris)...
[edit]: pdf is updated now

Jerome
Posted by Sam (Guest)
on 18.05.2006 20:17
I try your script.
Sorting work but i think i never use this :

function updateHeader( liveGrid, offset ) {

$('bookmark').innerHTML = "Listing records " + (offset+1) + " - " +
(offset+liveGrid.metaData.getPageSize()) + " of " +
liveGrid.metaData.getTotalRows();
var sortInfo = "";
if (liveGrid.sortCol) {
sortInfo = "&data_grid_sort_col=" + liveGrid.sortCol + 
"&data_grid_sort_dir=" +
liveGrid.sortDir;
}
$('bookmark').href="index.php" + "?data_grid_index=" + offset + 
sortInfo;
}

So i never update listing records and i don't know why ...

anyone have this error ?
Posted by Sam (Guest)
on 18.05.2006 20:22
All it' ok !
ON your pdf is :
new Rico.LiveGrid ("data_grid",6, 10, "xml_maker.php");

and i put this and it's good :
new Rico.LiveGrid ("data_grid",6, 10, "xml_maker.php",opts);
Posted by Jérôme
on 19.05.2006 06:34
yep...sorry for missing "opts" in pdf...i ll change it today...

[edit]:pdf updated
Posted by Neg (Guest)
on 23.05.2006 09:45
Hi all,

   In the tutorial, when you create the HTML table, you initialises 
contents of each table's lines with a request, but the rico's script 
filled the HTML table, with the result of his own request, with the 
loading of the page. So why just let rico's script filled the table and 
just create the HTML table with vacuum lines ?

Antho.

PS : sorry for my poor english (voila traduction french->english)
Posted by guus (Guest)
on 23.05.2006 10:10
Hi,
I copied the code from the pdf and created a page on our server.
I have a mysql table with 10.000 rows (yes I need to test it with
large resultsets).

The example is here: http://www.rldev.net/rico/index.php

In IE if I move the scrollbar to the last row (10000), then
move the scrollbar to the first row. --> stack overflow in my browser
I use IE 6.0.2900.2180.xpsp_sp2

In FF it works ok.


guus




Posted by Vivek (Guest)
on 03.06.2006 08:05
Hi!

During the first call of updateHeader in index.php where do we get the 
offset value from? And how are you passing the parameters to the 
xml_maker.php. I am planning to use jsp to create response. Do I need to 
say this way in the URL "xml_maker.jsp?offset=0&page_szie=20"??

Vivek.
Posted by Jay Blackwood
on 11.06.2006 00:44
Attachment: livegrid.zip
>>>> Please note that a file is available
>>>>    see "Attachment: livegrid.zip" in this posting's headers. 


Thanks for getting the basics in place.  I did find a few problems with
it.

I've taken the time to make a "plug-n-play" version of your stuff so
there are fewer errors for a newbie looking at it.  Basically I put all
the files together in one place that should be ready to install along
with a few simple instructions.  It even includes the SQL to populate a
database.

Anyhow, I fixed a few errors (see the README.txt file), re-indented the
code to my liking (for better readability),  and made one enhancement.
The enhancement allows the code to dynamically change the number of rows
to be displayed based on what's in the database (rather than the hard
coded value used).

One thing I discovered is that the sort doesn't seem to work using the
data I created which has 120 rows.  If you attempt to sort by Genre or
Title you should see some duplicates grouped together and they are not.
Perhaps you tell us what the fix would be for that or I'll get to it
sooner or later.

To see what I've done download the livegrid.zip file (see the link at
the top of this post)


-------------
READ ME

These files were "extracted" from Jerome Sadou's Tutorial on
how to use Rico's LiveGrid
(http://jerome.sadou.free.fr/jerome/doc/RicoLiveGridPhpEnglishHowTo.pdf)

I began by just trying to follow directions but there are errors and
"left to the reader"
issues to deal with.  I attempted to clean up the indentation (to my
liking) and fix the errors
and mimimize the "left to the reader" exercises.  The result was a fixed
set of files
(shown below) and the following instructions which should work.

-----------------------------
Still Left to the reader
-----------------------------
1) You must create the database 'photogallery'

2) Add a user named 'login' with the password 'password' to the
photogallery

3) In a tool such as phpMyAdmin go the photogallery database, select SQL
and "run"
   the gallery.sql file.  This should build the gallery table and add
120 rows to it.
   Of course these "instructions" are vague because I have no idea how
you do this -
   I only know how I do it!

4) Copy all these files to a directory (folder) of your choosing on your
web host
   (or anywhere you can process php files)

5) Cross your fingers, knock on wood three times, pray to the powers
that be,
   and open the index.php file in a browser of your choice.  It should
work.

-----------------------------
Files:
    README.txt            - this text

    index.php             - as described by Jerome Sadou
    xml_maker.php         - as described by Jerome Sadou
    images/sort_asc.gif   - from Jerome Sadou's site -
http://jerome.sadou.free.fr/grid/
    images/sort_desc.gif  - from Jerome Sadou's site -
http://jerome.sadou.free.fr/grid/
    js/prototype.js       - version 1.4.0 from
http://prototype.conio.net/
    js/rico.js            - version 1.1.2 from openrico.org

    gallery.sql           - an sql file to build the table and populate
it
                            (with 120 entries -which is more than the
original example)

-----------------------------
Changes from the original

    - index.php - changed the width of the date filed to 80px
                  (it was too small in my browser)
    - index.php - Added support to dynamically determine the size of the
database
                  rather than hardcoding.  the size (which was set at
15)

    - xmlmaker.php - the line "$title=$msg_data['gal_title'];" uses the
wrong db column name
                     "title" where it should have been "titre".

-----------------------------
Bugs
    - Sorting does not seem to work correctly - for example there are
multiple "Genre 1" in
      the Genre column.  Sorting by this does not seem to do the right
thing.

-----------------------------

Jay Blackwood
Ottawa, Ontario, Canada
June 10, 2006
Posted by Joerg (Guest)
on 13.06.2006 09:33
I tried the code, but there seems one error left. Bookmark won't work 
for me and i need the bookmark function. If i use the bookmark link 
nothing happens. Any help?

And why set the var data_grid_index and don't use it!?
Posted by Josip Lisec (Guest)
on 15.06.2006 11:42
Is it possible to make it searchable? How?

And thanks for a great tutorial :)
Posted by Cristina (Guest)
on 25.06.2006 22:40
I tried to execute this example, but I didn't get. It didn't execute 
xml_maker.php.
Can I help me?
Thanks
Posted by Mark Manley
on 26.06.2006 18:06
hi - It's working pretty well - when I click on a column header, 
however, the page returns no records at all. Any ideas why not?

thanks in advance!
Posted by nadeem lalani (Guest)
on 27.06.2006 09:54
Hi,
I tried the above example with a little modification to accomodate
oracle database, everything seems to be fine except when I click on the
col header I dont get any result, I confirmed that my backed script
(xml_maker.php) is getting called and it returning an ajax response xml,
but the response does not seem to get rendered into the table.

thanks.
Posted by Jay Blackwood
on 27.06.2006 13:03
Did you put it on webhost or a place/partition where PHP is processed? 
If you put it on a webhost can you supply a URL?

If you truely want help, please supply much more information on what the 
problem is.
Posted by Mark Manley
on 27.06.2006 17:15
all,

I solved the sorting problem.
In the xml_maker.php file, the switch statement was comparing with 
"Title", for example, when it should have been comparing with "title". 
This is true for all of the case statements there. Since the upper-case 
version was not found, the default $sort_col value was being used 
(gal_id).

so just change these 4 items to lower case and you're back on track.

mark
Posted by Chris Coppenbarger
on 29.06.2006 13:26
Yeah, I figured out the lower case problem a long time ago.

When you send the request to the backend page, Rico lowercases the sort 
columns.

I just updated my livegrid that I'm using to display courses from three 
different schools at the University I work at. I had some errors I 
didn't know about, but I made some changes to the update header function 
to fix them. It has to do with how many rows are in the table you're 
using. Of course, if I go over 30 rows in one of the sql calls, I'm in 
trouble. :)
Posted by Mark Manley
on 30.06.2006 17:04
Has anyone created an http call from one of the drop-down menus (on 
click in header or data)??? I'm interested in calling a 'detail' page 
based on the entry in a row. This will allow all master data for a 
person to be displayed, which in my case is quite a bit.

thanks in advance,
Mark
Posted by Pat Paquet (Guest)
on 24.07.2006 13:38
Hi,

Thank you for your example, but I have two problems with it.

First, I have a lot of difficulty to run it locally on my PC. I'm using 
Apache. Is there some known issues about the compatibility of Apache and 
the livegrid?

Also, when I run it on the Web, it works great with FireFox, but with 
Mozilla and Internet Explorer 6, it takes a long time before refreshing. 
My first page is rendered well, my columns are full of my data, but when 
I try to scroll in IE or Mozilla, the data only appears 40-50 seconds 
after. I wonder if someone knows something about those two issues...

Thanks a lot.
Posted by Richard Cowin
on 25.07.2006 03:36
The 40-50 second issue sounds very odd.  Is this on the first scroll?
You might try fiddler to help diagnose where the delay is.

Also, one of the bigest problems with IE and Ajax is the caching.
Not sure if it will help, but you might check out: 
http://forum.openrico.org/search?query=caching&forums%5B%5D=4&forums%5B%5D=8&forums%5B%5D=5&forums%5B%5D=6&forums%5B%5D=7&forums%5B%5D=9

Posted by Pat Paquet (Guest)
on 25.07.2006 13:27
Hi all,

The 40-50 seconds happen on every scroll or sorting I do. It looks like 
it's a caching problem, but I'm not sure. I try some things that people 
tried in this forum but nothing changed.

Thank a lot.
Posted by Pat Paquet (Guest)
on 26.07.2006 14:52
Hi all,

I found my problem, but I have another one. The delay was due partially 
to a cache problem with Internet Explorer. I have solve this problem by 
passing an inferior date in the header of the xml. 
http://en.wikipedia.org/wiki/XMLHTTP

The second problem is that I have a data with an accent. (Ex: name = 
André Something). This cause Internet Explorer to not fill the grid with 
data and causing the delay. Is there something I must do to Rico or to 
Prototype to solve it? I tried to use the PHP function htmlentities, 
it's working well, I saw my accent was converted in my fiddler, but the 
grid stays empty. In FireFox, it's working very weel though, I don't 
even need to convert the string...

Thanks and sorry for my bad english...
Posted by Jay Blackwood
on 26.07.2006 17:22
Special characters need to be represented in HTML it special codes. For 
example an ampersand (&) uses the code '&amp;'.  the é in André must be 
represented by the code '&eacute;'  See 
http://www.w3schools.com/tags/ref_entities.asp for a list of these 
characters and how they must be represented.

In php use either htmlentities() or htmlspecialchars(). See
http://www.php.net/manual/en/function.htmlspecialchars.php for more on 
this.
Posted by Pat Paquet (Guest)
on 26.07.2006 17:50
Hi all,

Thank you for your help.

I tried this in xml_maker when it generates the xml.

      $id = $msg_data['id'];
      $title = $msg_data['name'];
      $title = str_replace("é","&#233",$title);
      $title = str_replace("à","&#224",$title);
      $genre = $msg_data['address1'];

It doesn't work. I try this too.

      $id = $msg_data['id'];
      $title = $msg_data['name'];
      $title = htmlentities($title);
      $genre = $msg_data['address1'];

It doesn't work either. On both cases, the convert is made because I can 
see it in my fiddler. My trouble is as soon as I scroll or I try to sort 
by clicking on a title, my grid stays empty. Only in IE though...

Thanks for your help.
Posted by Pat Paquet (Guest)
on 26.07.2006 19:19
Hi,

I finally solve my problem.

I use this function:

function allhtmlentities($string)
{
   return preg_replace('/[^\x00-\x7F]/e', '"&#".ord("$0").";"', 
$string);
}

and I call it like that in my XML.

$id = $msg_data['id'];
      $title = $msg_data['name'];
      $title = allhtmlentities($title);

As simple as that....

Thanks.
Posted by Kiran (Guest)
on 29.07.2006 11:45
HI man!!!!!!!!!!!

 Big thanks from my side.

 It is really helping a lot for my application.................

once again thanks man..

Regards,
Kiran.P
Posted by alex (Guest)
on 18.08.2006 12:37
cool excellent work!

do you know how i could do the same with jsp
Posted by jami mil
on 20.08.2006 08:16
Nice work!  thanks much for the tutorial.  it worked great!
Posted by alex (Guest)
on 21.08.2006 14:34
the scroll doesnt work anymore
Posted by alex (Guest)
on 21.08.2006 16:33
PLEASE REPOST THE ZIP FILE AGAIN IT DOESNT WORK ANYMORE IT WORKED TWO 
DAYS AGO!!!!
Posted by alex (Guest)
on 26.08.2006 14:06
i ran the example as well and there is no scrollbar may i see your 
source code
Posted by Arvinder Singh
on 01.10.2006 14:08
You can use cdata around the block of characters to solve this problem. 
In one of my projects I was getting & as part of rico grid response. so 
I included the part that contained the & in cdata to solve the problem. 
e.g.

<td><![CDATA[ your data that contains any special chars that cause xml 
parsing problem in RICO grid.]]></td>
Posted by Mark Manley
on 18.10.2006 20:46
Hi,

I've not been able to display multi-byte characters in the grid. The
database is set up correctly; I can see Japanese properly via
phpMyAdmin.

I've added the following to the <head> area of the grid page, but it
doesn't help.
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
pageEncoding="UTF-8">

I've also modified the dbclass.php page, (within the class dbClass_mysql
section) as such (I inserted the SET NAMES line...):

  function RunQuery($sqltext)
  {
  		mysql_query('SET NAMES utf8');
  		return mysql_query($sqltext,$this->conn);
  }

Any ideas what else I can do?

Thanks in advance!
Posted by Ken Gregg
on 18.10.2006 21:37
Check the encoding in the xml you return.
Posted by Mark Manley
on 19.10.2006 20:24
Hmm - I'm using the example and looking at the northwindxmlquery.php 
file, which is where i'd expect to see this, but i'm seeing not much 
reference to XML code (just the header xml statement which I changed 
from iso-8859 to utf-8, to no avail). I did notice the function 
Query2xml, but I'm not seeing any character translation except for 
htmlspecialchars. Am I barking up the wrong tree here?

Has anyone had any success utilizing the demo files for displaying 
multi-byte characters? I *think* I was doing it in earlier versions of 
the tool, but looking at the earlier versions of the demo code turned up 
nothing so far.

thanks in advance!
Posted by allen fox
on 03.11.2006 09:32
This was such a huge help.  Thanks a ton for posting this and getting
the sorting working.

I did run into a slight issue with my server config.  I would load up
the grid and as soon as I scrolled the data would vanish (or not
populate is a better way to express this).  This was because
$_GET['pagesize'] is undefined and the install of PHP on my dev server
had the display_errors directive set to "on".

so 2 ways to fix it. define it or turn off error display in php.

on a side note - has anyone noticed the performance issues with a larger 
data sets using mysql and php?
Posted by Mark Manley
on 03.11.2006 15:50
I've solved the final problem displaying multi-byte characters and want 
to pass the info on. There are three steps to making the LiveGrid demo 
multi-byte capable:

1. in the header of the demo.php file,  after the <title> area, you need 
to add:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" 
pageEncoding="UTF-8">

2. in the dbclass.php file, in the function called MySqlLogon, you need 
to add the following line:

 	mysql_query('SET NAMES utf8');

- add it just before the return true; statement

3. in the northwindxmlquery.php file add the following line:

print '<?xml version="1.0" encoding="UTF-8" ?'.">\n";

- add it after the header() statements at the top. there is already a 
print statement there for ?xml version..., so comment that one out or 
simply replace it with the one above.

Hope this helps someone!
Mark
Posted by rob xyz
on 27.11.2006 12:09
Hey!!

First of all THX for your example! It really helped me!!!!!

But there is one little problem left!!!

Info:
When I first creat the table, every <tr> got an ID. <tr id="1234">

Problem is....
If I sort the grid (click on the livegrid-header)the values of the table
changes BUT THE ID's doesn't! The values of the <tr ID="1234"> stays the
same! Now the ID's doesn't mach with the entries in the row!

How can I solve this problem!

looking forward to your replys!

greets from austria!
Posted by Andrew Nash
on 12.01.2007 02:14
Thanks. I really appreciate your help in taking the original tutorial 
and pointing out the few bugs. It was very helpful in getting me over 
the hump.
Posted by Mike Wa
on 29.01.2007 20:17
I am fairly sure i followed the tutorial accurately. Seems to make
sense.

So far I have the initial grid showing the first 10 queried items, but
as soon as I scroll up or down everything goes blank.

I've looked it over around 30 times for something I might have missed
but I can't seem to figure out.

Any suggestions? Thanks.
Posted by laporte xavier
on 31.07.2008 07:30
Hi !

I would like ton add an action when i click on a cell of the grid.
The action is not a livegrid action but my owner action.

For example, when i click on a cell i must to actualize an input.

(my livegrid is in a popup list and i must to actualize the opener...)

Thanks for your help.

Sorry but I'm french... my english i not perfect !