Page 1 of 1

Column names repeated on end of the list.

PostPosted: Tue Oct 30, 2012 3:24 pm
by Gwynnbleid1
Hi. I was asked by my users if I can add column names also on the end of the list view. Is it possible ?

Re: Column names repeated on end of the list.

PostPosted: Tue Oct 30, 2012 3:51 pm
by shannah
Do you need to do it dynamically or are there just some additional calculated columns you want to include?

Steve

Re: Column names repeated on end of the list.

PostPosted: Tue Oct 30, 2012 11:27 pm
by Gwynnbleid1
shannah wrote:Do you need to do it dynamically or are there just some additional calculated columns you want to include?

Steve

I I dont wont to add columns. I just want to repeat column names at the bottom. Like this:


Table A:

ColumnA ColumnB ColumnC
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
data1 data2 data3
ColumnA ColumnB ColumnC

As you can see if there is lot of rows then repeated column name in bottom would help you keep track of where you are.
Data in table in question consist mainly of numbers.

Re: Column names repeated on end of the list.

PostPosted: Wed Oct 31, 2012 7:38 am
by shannah
The easiest way to do this would be using Javascript (jquery) to copy the thead of the table and insert it into a tfoot in the table.
e.g.
Code: Select all
var $thead = jQuery('#result_list thead').clone();
var $tfoot = $('<tfoot>');
$tfoot.append($thead.children());
jQuery('#result_list').append($tfoot);


Or something like this. (This actual code is untested).

-Steve

Re: Column names repeated on end of the list.

PostPosted: Wed Oct 31, 2012 7:46 am
by Gwynnbleid1
I tried to add it in Dataface_List_View.html file and got: Undefined variable: jQuery
So the place isn't ok for this code. Can you suggest a place to add this ?

Re: Column names repeated on end of the list.

PostPosted: Wed Oct 31, 2012 7:55 am
by shannah
Ahh.. In 1.3.x and earlier, jQuery is included only where needed. I guess in list view it isn't included yet.
In 2.0 with the g2 theme it is always included.

So for 1.3.x, you can do this in two ways.
In your block, include both jquery and your script. Jquery is located in js/jquery.packed.js.
Or you could use the Javascript tool (inside your block also).

e.g. In your delegate class (application delegate for all tables or table delegate for particular table)
Code: Select all
function block__before_result_list(){
    echo '<script src="'.htmlspecialchars(DATAFACE_URL.'/js/jquery.packed.js').'"></script>';
    echo <script src="'.htmlspecialchars(DATAFACE_SITE_URL.'/js/myscript.js').'"></script>';
}


Or using the Javascript tool,
Code: Select all
function block__before_result_list(){
    Dataface_JavascriptTool::getInstance()
        ->import('myscript.js');
}

Then in your script you could use the Javascript tool's require directive to make it "require" jquery.
In js/myscript.js
Code: Select all
//require <jquery.packed.js>
.. the rest of my javascript.


-Steve