Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: RFC : AJAX + DBI = DBIx::LiveGrid

by jZed (Prior)
on Sep 15, 2005 at 14:40 UTC ( #492247=note: print w/replies, xml ) Need Help??


in reply to Re: RFC : AJAX + DBI = DBIx::LiveGrid
in thread RFC : AJAX + DBI = DBIx::LiveGrid

Well, I'm still thinking about that one since it's something I plan to do too. I may add the ability automatically, but currently, you need to do it manually by replacing the $liveGrid->build_ajax_table() method with your own method. The method should accept an array of arrayrefs AoA (which will have been built automatically from a selectall_arrayref call or else built manually if you prefer). Loop through the array and add anything you want around the data values. Just remember that what you send must be valid XML. Since XHTML is a subset of XML, this can include XHTML, in this case anchor hrefs. See the docs for build_ajax_table() for details.

I'm afraid I can't be much help in terms of things like fonts and scrollbars -- I wrote the Perl end, not the JavaScript end (except for the make_grid() JavaScript) - all of the other JavaScript is from the folks at openRico and prototype. See their site (the same site as the demo above) and help forum for possible scrollbar fixes. One thing I know is that you probably do *not* want cells that are more than a row deep since that can throw off the scroller.

update One thing you can try wrt the scrollbars is to replace the make_grid() Javascript call with an actual hard-coded XHTML table (with cells containing non-breaking spaces) that will serve as the container for data. To see how this is constructed, read the Rico docs and do view source on the Rico demo. The main thing is to have the grid ID (data_grid in the examples) appear in the ids of the table as shown in the Rico demo.
  • Comment on Re^2: RFC : AJAX + DBI = DBIx::LiveGrid

Replies are listed 'Best First'.
Re^3: RFC : AJAX + DBI = DBIx::LiveGrid
by srdst13 (Pilgrim) on Sep 16, 2005 at 13:16 UTC

    Would it be possible include a hook or code_ref for a column to make transformations of the data simple? For example, you could imagine wanting to color certain fields red based on a value in the field. This could be easily done outside of your module context, but it might make a nice addition, since it would certainly streamline the process from DBI-->AJAX.

    Sean

      Yes, I'll do that. I'll just wait for this first round of comments and then add that in to the release.

      update

      Acutally I am thinking it should be available as a hook in the Perl script but also as something that can be specified from the JavaScript end - e.g. add two optional arrays to the config in the HTML page for pre_column_txt and post_column_txt. E.g. if you want red around column two:
      var pre_column_txt = new Array(undef,'<span style="color:red">'); var post_column_text = new Array(undef,'</span>');
      How's that sound?

      update2

      Oh, I remember how it sounds :-). It sounds like an easy way to send cross-site scripting attacks. :-) Maybe I'll only do a hook after all. :-)
        I was thinking from the perl end, also. But I have to admit that my javascript is not up to snuff. Thanks for considering the addition. I am looking forward to the release.
        Sean
Re^3: RFC : AJAX + DBI = DBIx::LiveGrid
by zby (Vicar) on Sep 15, 2005 at 21:52 UTC
    I was thinking about doing it the other way around - submitting the links as data in the AoA of data (and somehow disabling the html escaping of data entities).
      Sure, you can do it that way too. I made it so all methods are easily replaceable. The query_database() method returns an AoA of data, then the build_ajax_table() wraps the rows of the AoA in 'tr' tags and for each column in the row, cleans the XML and wraps it into 'td' tags. You can make a method that does both things at once, and just feed the results to send_ajax_response() without calling either of the built-ins.

      I am thinking of something more generic for "drill-downs" - basically make it so you can specify any column as a drill-down column, which will automatically create an href around the values in the column that when clicked will do a WHERE col = val (e.g. you click on "Africa" in the "region" column and that will "drill-down" to WHERE region = 'Africa').

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://492247]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2022-05-17 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (68 votes). Check out past polls.

    Notices?