Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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

by zby (Vicar)
on Sep 15, 2005 at 10:55 UTC ( #492162=note: print w/replies, xml ) Need Help??

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

Really great!

I have a question - in the application I plan I need to put links in the data cells. The links should go back to the same table filtered by the value in the cell. I see you display the address of the table with the position and order in the "Listing movies ..." link, and I want to ask what is the easiest way to extract it and use (after adding the filtering parameters) inside the cells.

And one more note - in firefox with big fonts I cannot see the scrollbar.

Replies are listed 'Best First'.
Re^2: RFC : AJAX + DBI = DBIx::LiveGrid
by jZed (Prior) on Sep 15, 2005 at 14:40 UTC
    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.

      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.


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


        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?


        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 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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2022-05-25 07:26 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (85 votes). Check out past polls.