Data Grid PHP Class 1.0 BETA 3

Tuesday, May 15, 2007
,

A new version of the Image Manipulation PHP Class has been released. Read further to see what is new in this version of the script.

What's new in this version:

  • on popular request, arrays can now be passed to the grid for displaying
  • setting the the default sort column was working correctly only the first time the grid was displayed. if the grid's form got submitted (by a custom action), the grid would be displayed as unsorted
  • when there were no records to display, the grid would produce a JavaScript error
  • the message to be displayed when there are no records, can now be customized on the fly with the use of a new property called "noDataMsg"
  • unsetting action fuctions, enabling/disabling sorting can now be done to multiple columns at once
  • check all/uncheck all/invert selection was not working if the grid was showing a single record
  • the layout of check all/uncheck all/invert buttons can now also be set from the template
  • until now, the form was submitted to itself by default. now this can be set when instantiating the data grid
  • the template can now be set by using the newly added method "setTemplate()"
  • the language can now be set by using the newly added method "setLanguage()"
  • added romanian translation
  • added spanish translation (thanks to Gabriel Perez)
  • added simplified chinese translation (thanks to Xiaochen Wu)
  • PHP 4 was reporting some errors

26 comments:

  1. Jeroen Benats said...

    Hey!

    I just came across a little bug in the PHP Datagrid class. I haven't had the time to look into it (yet), but maybe you are already aware of the problem. I will when I have some spare time.

    When you set custom footer content (what I did was adding some text and a button to add the checked rows into a table in my database), javascript is acting weird.

    Check all / Uncheck all and invert selection are working fine. The combobox (how many records on page) and just clicking the page numbers result into an error.

    This is the message I get (line number can differ because I'm using also an other javascript):

    Line: 510
    Error: Object doesn't support this property or method.

  2. Stefan Gabos said...

    thanks!
    i'll look into it

  3. mark said...

    Hey,

    Excellent grid! (Who needs .net eh?).

    One thing, It doesn't render well in Firefox (IE is fine).

    The text is ok but no styles are applied. Can you explain what I need to do?

    Thanks!

  4. Stefan Gabos said...

    looks ok here. can you tell me more exactly how you've run it? or maybe send me a link?

  5. mark said...

    Ahhh...Whilst uploading a sample so you can see what I mean i discovered that it actually works ok on Firefox whilst running under Unix.

    It's just my dev machine (Windows) that it doesn't like.

    Why do you think that would be?

    Thanks.

  6. Stefan Gabos said...

    then you probably don't have the $_SERVER["DOCUMENT_ROOT"] available on your windows machine...not sure though

  7. Stefan Gabos said...

    jeroen, can you give me the code you've added to the footer? i looked into the code and couldn't find anything wrong with it. can it be that there's a syntax error in the code you're inserting?

  8. Jeroen Benats said...

    Hey Stefan,

    I'm at work at the moment so I can't access my sources from here. I'll send it to you later.

    I also fixed something in the class. After the preg_match_all (when using SEO), there is this line:

    // if does, use that as current page
    $this->currentPage = $matches[1];


    This has to become:

    $this->currentPage = $matches[0][0];

    (since preg_match_all returns a multidimensional array)

    Greetings!

  9. Jeroen Benats said...

    Ok, here's what was wrong:

    I had a submitbutton in my footerHTML for submitting the selected records to my database. That button was the cause because it was conflicting with your javascript method to post the form when changing pages/Amount of records shown (function: customSubmit()).

    I changed it to an image button for now and it works, but that's certainly something to look into.

    The Firefox console came up with: 'document.cnwyqaxq.submit is not a function', thrown by the customSubmit function.

  10. Stefan Gabos said...

    most probably your button's name was "submit"

  11. Jeroen Benats said...

    Yes it was.

    But I also tried renaming it to 'submitAgenda', without success.

  12. Adriano said...

    Nice grid, i like this,
    but when i try use this in my code, found a problem

    function custom_content($value)
    {
    return "[delete]";
    }

    This code don´t work
    the variable $value is empty
    i need a value, cod, id, name , some thing of the row.

    Maybe you can help me?

  13. Stefan Gabos said...

    change your function to look like

    function custom_content($value, $columns)
    {
    return "[delete]";
    }

    now $columns will be an associative array with all the fields of the row

  14. C. said...

    Hi Jeroen,

    Your datagrid looked exactly what I needed - but it didn't take me long to find the first bug :(

    I uually do my development in /home/colin/public_html/project/ which is then accessible via http://localhost/~colin/project/
    (my document root is somewhere else altogether).

    Unfortunately the datagrid disagres and thinks the css should be in http://localhost/home/colin/public_html/project/datagrid/templates/default/style.css

    :(

  15. mark said...

    hi,

    Found the old comment now (mentioning DOCUMENT_ROOT) but changing this has no effect (even adding it as an environment variable under windows did not work). Styles are simply not applied under IIS.

    Any ideas how to fix this?

    Thanks

  16. mark said...

    ok so editing the template file so that the path to the css is hard coded works ok.

    I will use this as a work around.

    Thanks again!

  17. nuno.basto said...

    Hi,

    First of all, thank you for this Data Grid Class! It's amazing!

    Now, my problem is from a simple example:
    I have two tables: clients and projects.
    When using datagrid to display the table projects, one field is client_index that gets a call back function to display the name from the clients table. How can I sort this table by client name instead of client_index? When I click the Client column, in spite of displaying the name, it sorts by its index.

    Thanks.

  18. Wayne Blumstengel said...

    Hi ... as all those before me have already stated ... great DataGrid Class.

    I am attempting to use the getRow ActionFunction method to assign the selected row values to the $_SESSION super global.

    function action($value, $columns)
    {

    $_SESSION["user_row_data"] = $columns;

    }

    but the method only grabs the values from the last row currently displayed in the grid. If I display only one row in the grid, I get the values I expect. If the grid is displaying more than 1 row of data, I get the values from the last row. Am I doing something wrong here?

  19. admin said...

    I have looked at a new sample of your grid. Is it possible to use it to edit and update data? Or even to insert new data lines? Looking at a php solution to data entry using something similar to the datagrid in vb.

    Smoothice

  20. Anonymous said...

    Hello!
    First of all I want to thank for this awesome effort. I want to use this class to display my custom array. So I have downloaded and set it up on my localhost at this location "http://localhost/testing/datagrid". But I couldn't see anything when I click on any link(both pagination and sorting are not working, it seems). Or may be I should change some settings in the code. But there is no mention of things like this in your documentation. Please help as soon as possible!

  21. Paul said...

    Hi, I really like this script and want to start using, but keep getting an error message of:

    Warning: Missing argument 2 for dataGrid::dataGrid(), called in C:\wamp\www\ajaxgrid\examples\sql_example1.php on line 30 and defined in C:\wamp\www\ajaxgrid\class.datagrid.php on line 253

    This is using:

    php 5.2.5
    mysql 4.1.22
    apache 1.3.37

  22. Paul said...

    Can anyone explain how you would pass 2 or more arguments/variables to the SetCallBackFunction? I've tried the below, but it doesn't work.

    $grid->setCallbackFunction(array("time_limit","gid"), "css_timelimit");

  23. Stefan Gabos said...

    you can't do that.

    $grid->setCallbackFunction(array("time_limit","gid"), "css_timelimit");

    means that for the "time_limit" and "gid" columns, the "css_timelimit" function will be assigned.

    The user defined function takes as parameter the value of the field where the function is run and, optionally, an array containing all the available fields and their respective values for that particular row

    therefore, your function must look something like

    function css_timelimit($col, $row)
    {
    // this will print the actual value of "time_limit" and "gid" columns for each row
    print_r($col);

    // while this will print ALL the values from each specific rows
    print_r("<pre>");
    print_r($row);

    }

    the user-defined functions can't have other arguments.

    hope this helps

  24. Rob said...

    Are there any plans for further development? Since you are still at beta3, so I'm wondering what the future will be?

  25. muta said...

    Hi
    I am trying to use your datagrid class but I am facing a problem.I am calling the page that displays my table with ajax, i cant move to next page or change the page size.These functions only work if i call the displaying page on its own..Plz help

  26. Leandro said...

    congratulations, it's great.
    i tried put a selector column to delete some selected rows clicking on the field name or (preferencialy) a picture on top and returning to the grid, without a submit buttom or send like a form, just using this JS code that should recieve a array with the selected rows.
    in yours examples i can't to adapt like a callfunction or other.

    Thanks.

    >
    function delete(Cod){
    var answer = confirm('Are you sure?');
    if (answer){
    location = 'pedido_action_exc.php?cod='+Cod;
    }
    }

Post a Comment

GlossyBlue Blogger by Black Quanta. Theme & Icons by N.Design Studio
Entries RSS Comments RSS