Result page column with

Femax

New member
Hi,

Great application, I used it to create an archived of our logbooks for research purposes.

Only one thing, I have 5 fields (column) on my results page and I would like to know how I can individally set the width of each column result.

I have the following column
- Date --> small width required
- Number --> small width required
- Name --> small width required
- Comments --> large width required
- Action --> small width required

I've play with the different $word_wrap_ setup in config.php but no luck.

So if you can help me it would be great.

Thanks for your support.

 

alpha2zee

Well-known member
Column widths are not individually set in DaDaBik and are usually dictated by the largest table cell in the page.

You can try editing function build_results_table in include/business_logic.php. The idea is to add MySQL table and field-name specific style (that is, width) parameters to the table cell (<td>). Find (line 2547 in my DaDaBik 4.0 alpha)
[pre]
$results_table .= "<td class=\"".$td_results_class."\">"; // start the cell;
[/pre]
and change to
[pre]
$results_table .= "<td class=\"".$td_results_class."\" ";// start the cell;
if ($table_name == 'xxx' and $fields_labels_ar[$i]["name_field"] == 'yyy'){
$results_table .= "style=\"width:50px; \"";
}
elseif ($table_name == 'xxx' and $fields_labels_ar[$i]["name_field"] == 'zzz'){
$results_table .= "style=\"width:150px; \"";
}
elseif ($table_name == 'xxx' and $fields_labels_ar[$i]["name_field"] == 'aaa'){
$results_table .= "style=\"width:250px; \"";
}
else ($table_name == 'xxx' and $fields_labels_ar[$i]["name_field"] == 'bbb'){
$results_table .= "style=\"width:350px; \"";
}
$results_table .= ">"; // end starting of cell
[/pre]
Set xxx, yyy, zzz, aaa, bbb, etc., to the table name and the field (column) names. Note that if..elseif..elseif.....else pattern.

Also note that you can pass other parameters (such as background color, etc.) by using code like
[pre]
$results_table .= "style=\"width:50px; background-color: #FFFFFF;\"";
[/pre]
One can have this implemented as an extra DaDaBik feature as a 'mod.' This will involve having a new field (say, 'style') in the internal table DaDaBik uses. Then one can just use this code
[pre]
$results_table .= "<td class=\"".$td_results_class."\" style=\"".$fields_labels_ar[$i]["style"]."\">"; // start the cell;
[/pre]
(DaDaBik sets up an internal table for every table it manages; usually they have the same name as the managed table, but with a prefix; such as 'dadabik_books' for the 'books' table. For every field in the 'books' table, there is a row in the 'dadabik_books' internal table that dictates parameters such as whether that field should be shown in the results table, whether it should be a required field in the forms, etc.)
 

Femax

New member
Hi,

Thanks for your quick reply.

I will play with this code. But I have one question, because I have multiple tables, 9 totals but they all have the same structures, it's just that they represent differents years for each logbook (1997, 1998, etc...). Will this change apply to all or only affect one table.

Thanks again,

Mario
 

alpha2zee

Well-known member
If you want the same structure for all the tables (and all the tables have the same fields), you can skip the $table_name conditional. That is, for example, use
[pre]
($fields_labels_ar[$i]["name_field"] == 'yyy')
[/pre]
instead of
[pre]
($table_name == 'xxx' and $fields_labels_ar[$i]["name_field"] == 'yyy')
[/pre]
 

Flagio

New member
Hi, I was trying to implemented it as an extra DaDaBik feature as a 'mod.', like you said. But if I'm right I have to change more then:

$results_table .= "<td class=\"".$td_results_class."\" style=\"".$fields_labels_ar[$i]["style"]."\">"; // start the cell;

and add that 'style' field to a dadabik_ table?
Because nothing is happening, although I do see the style="" added to the td
Thx

(using DaDaBik 4.0 alpha)
 

alpha2zee

Well-known member
For the mod to work, more is needed than changing that results_table line. Something like this -

Modify internal tables
You will have to add a new field - style_field - of type varchar(255) should be fine - to all the dadabik_ prefixed internal tables.
For future table installations and refreshes
So that the new field gets added automatically, edit function create_internal_table in business_logic.php, adding this before the closing bracket [ ) ] after putting a comma [ , ] at the end of the preceding line
[pre]
style_field C(255) DEFAULT '' NOTNULL
[/pre]
That's for version 4.0 alpha. For 3.2, similar but slightly different - style_field varchar(255) NOT NULL default ''. Then edit case: refresh_table under switch($function) in admin.php, adding this after the line beginning - $linked_fields_order_type_field_temp
[pre]
$style_field_temp = addslashes($fields_labels_ar[$j]["style_field"]);
[/pre]
For the parameter to be presented in the form configurator
Edit internal_table.php, adding before the [ ? ] at the end
[pre]
$int_fields_ar[25][0] = "Table-cell style:";
$int_fields_ar[25][1] = "style_field";
$int_fields_ar[25][2] = "text";
$int_fields_ar[25][3] = "25";
[/pre]
Now, a text-field, 25 characters, wide, will be presented for entering style options. If it too short, you can increase the value. See if you can figure out a way to have a textarea (say 25 x 3) instead.
For the display
Edit build_results_table function in business_logic.php. Find
[pre]
for ($i=0; $i<$count_temp; $i++){
if ($fields_labels_ar[$i]["present_results_search_field"] == "1"){ // the user want to display the field in the search results page
$results_table .= "<td class=\"".$td_results_class."\">"; // start the cell
[/pre]
Edit the last line to be so
[pre]
$results_table .= "<td class=\"".$td_results_class."\" style = \"" . $fields_labels_ar[$i]["style_field"] . "\">"; // start the cell
[/pre]
A little above find
[pre]
$results_table .= "<th class=\"results\">";
[/pre]
Change to
[pre]
$results_table .= "<th class=\"results\" style = \"" . $fields_labels_ar[$i]["style_field"] . "\">";
[/pre]
Usage
One would enter CSS-style values in the field. Normally, styles are dictated so -

style="color:green; background-color:white; width:25px;"

But in the field one would enter -

color:green; background-color:white; width:25px;

Issues

Note that there may be some style inheritance issues. And also that the th (table header) tag may not accept or may impose on the cells certain style values. It should not break any code though.

Please post if this works, or if you had to modify other things too.



Post Edited (11-30-05 15:54)
 

Flagio

New member
wonderful, thx for your quick answer

at first it wasn't working, so here is what I changed to make it work (backup first!)

(version 4.0 alpha)
admin.php
line 195
find: $order_form_field_temp = add_slashes($fields_labels_ar[$j]["order_form_field"]);

add after:
$style_field_temp = add_slashes($fields_labels_ar[$j]["style_field"]);

line 308:
find:
$sql = "insert into ".$quote."$table_internal_name".$quote." (".$quote."name_field".$quote.", ".$quote."present_insert_form_field".$quote.", ".$quote."present_search_form_field".$quote.", ".$quote."required_field".$quote.", ".$quote."present_results_search_field".$quote.", ".$quote."present_ext_update_form_field".$quote.", ".$quote."check_duplicated_insert_field".$quote.", ".$quote."type_field".$quote.", ".$quote."content_field".$quote.", ".$quote."separator_field".$quote.", ".$quote."select_options_field".$quote.", ".$quote."select_type_field".$quote.", ".$quote."prefix_field".$quote.", ".$quote."default_value_field".$quote.", ".$quote."label_field".$quote.", ".$quote."width_field".$quote.", ".$quote."height_field".$quote.", ".$quote."maxlength_field".$quote.", ".$quote."hint_insert_field".$quote.", ".$quote."order_form_field".$quote.", ".$quote."other_choices_field".$quote.", ".$quote."primary_key_field_field".$quote.", ".$quote."primary_key_table_field".$quote.", ".$quote."primary_key_db_field".$quote.", ".$quote."linked_fields_field".$quote.", ".$quote."linked_fields_order_by_field".$quote.", ".$quote."linked_fields_order_type_field".$quote.") values ('$name_field_temp', '$present_insert_form_field_temp', '$present_search_form_field_temp', '$required_field_temp', '$present_results_search_field_temp', '$present_ext_update_form_field_temp', '$check_duplicated_insert_field_temp', '$type_field_temp', '$content_field_temp', '$separator_field_temp', '$select_options_field_temp', '$select_type_field_temp', '$prefix_field', '$default_value_field', '$label_field_temp', '$width_field_temp', '$height_field_temp', '$maxlength_field_temp', '$hint_insert_field_temp', '$order_form_field_temp', '$other_choices_field_temp', '$primary_key_field_field_temp', '$primary_key_table_field_temp', '$primary_key_db_field_temp', '$linked_fields_field_temp', '$linked_fields_order_by_field_temp', '$linked_fields_order_type_field_temp')";

replace with:
$sql = "insert into ".$quote."$table_internal_name".$quote." (".$quote."name_field".$quote.", ".$quote."present_insert_form_field".$quote.", ".$quote."present_search_form_field".$quote.", ".$quote."required_field".$quote.", ".$quote."present_results_search_field".$quote.", ".$quote."present_ext_update_form_field".$quote.", ".$quote."check_duplicated_insert_field".$quote.", ".$quote."type_field".$quote.", ".$quote."content_field".$quote.", ".$quote."separator_field".$quote.", ".$quote."style_field".$quote.", ".$quote."select_options_field".$quote.", ".$quote."select_type_field".$quote.", ".$quote."prefix_field".$quote.", ".$quote."default_value_field".$quote.", ".$quote."label_field".$quote.", ".$quote."width_field".$quote.", ".$quote."height_field".$quote.", ".$quote."maxlength_field".$quote.", ".$quote."hint_insert_field".$quote.", ".$quote."order_form_field".$quote.", ".$quote."other_choices_field".$quote.", ".$quote."primary_key_field_field".$quote.", ".$quote."primary_key_table_field".$quote.", ".$quote."primary_key_db_field".$quote.", ".$quote."linked_fields_field".$quote.", ".$quote."linked_fields_order_by_field".$quote.", ".$quote."linked_fields_order_type_field".$quote.") values ('$name_field_temp', '$present_insert_form_field_temp', '$present_search_form_field_temp', '$required_field_temp', '$present_results_search_field_temp', '$present_ext_update_form_field_temp', '$check_duplicated_insert_field_temp', '$type_field_temp', '$content_field_temp', '$separator_field_temp', '$style_field_temp', '$select_options_field_temp', '$select_type_field_temp', '$prefix_field', '$default_value_field', '$label_field_temp', '$width_field_temp', '$height_field_temp', '$maxlength_field_temp', '$hint_insert_field_temp', '$order_form_field_temp', '$other_choices_field_temp', '$primary_key_field_field_temp', '$primary_key_table_field_temp', '$primary_key_db_field_temp', '$linked_fields_field_temp', '$linked_fields_order_by_field_temp', '$linked_fields_order_type_field_temp')";

business_logic.php

line 345
find:
$sql = "SELECT ".$quote."name_field".$quote.", ".$quote."present_insert_form_field".$quote.", ".$quote."present_ext_update_form_field".$quote.", ".$quote."present_search_form_field".$quote.", ".$quote."required_field".$quote.", ".$quote."present_results_search_field".$quote.", ".$quote."present_details_form_field".$quote.", ".$quote."check_duplicated_insert_field".$quote.", ".$quote."type_field".$quote.", ".$quote."other_choices_field".$quote.", ".$quote."content_field".$quote.", ".$quote."label_field".$quote.", ".$quote."select_options_field".$quote.", ".$quote."separator_field".$quote.", ".$quote."primary_key_field_field".$quote.", ".$quote."primary_key_table_field".$quote.", ".$quote."primary_key_db_field".$quote.", ".$quote."linked_fields_field".$quote.", ".$quote."linked_fields_order_by_field".$quote.", ".$quote."linked_fields_order_type_field".$quote.", ".$quote."select_type_field".$quote.", ".$quote."prefix_field".$quote.", ".$quote."default_value_field".$quote.", ".$quote."width_field".$quote.", ".$quote."height_field".$quote.", ".$quote."maxlength_field".$quote.", ".$quote."hint_insert_field".$quote.", ".$quote."order_form_field".$quote." FROM ".$quote.$table_internal_name.$quote;

replace with:
$sql = "SELECT ".$quote."name_field".$quote.", ".$quote."present_insert_form_field".$quote.", ".$quote."present_ext_update_form_field".$quote.", ".$quote."present_search_form_field".$quote.", ".$quote."required_field".$quote.", ".$quote."present_results_search_field".$quote.", ".$quote."present_details_form_field".$quote.", ".$quote."check_duplicated_insert_field".$quote.", ".$quote."type_field".$quote.", ".$quote."other_choices_field".$quote.", ".$quote."content_field".$quote.", ".$quote."label_field".$quote.", ".$quote."select_options_field".$quote.", ".$quote."separator_field".$quote.", ".$quote."style_field".$quote.", ".$quote."primary_key_field_field".$quote.", ".$quote."primary_key_table_field".$quote.", ".$quote."primary_key_db_field".$quote.", ".$quote."linked_fields_field".$quote.", ".$quote."linked_fields_order_by_field".$quote.", ".$quote."linked_fields_order_type_field".$quote.", ".$quote."select_type_field".$quote.", ".$quote."prefix_field".$quote.", ".$quote."default_value_field".$quote.", ".$quote."width_field".$quote.", ".$quote."height_field".$quote.", ".$quote."maxlength_field".$quote.", ".$quote."hint_insert_field".$quote.", ".$quote."order_form_field".$quote." FROM ".$quote.$table_internal_name.$quote;

line 370
find:
$fields_labels_ar[$i]["separator_field"] = $field_row["separator_field"]; // the separator of different possible values for a select field

add after:
$fields_labels_ar[$i]["style_field"] = $field_row["style_field"]; // Table-cell style for a select field

this is all I changed...
Paul



Post Edited (11-30-05 17:13)
 

Flagio

New member
Just a quick attempt:

picture2.png


column 1
width:200px; BACKGROUND-COLOR: #2A2A2A; COLOR: #F6B620; border-bottom: 1px solid #565656; border-left: 1px solid #565656; border-top-color: transparent; border-top-style: solid; border-right-color: transparent;

column 2:
width:240px; BACKGROUND-COLOR: #2A2A2A; color: #888; border-bottom: 1px solid #565656; border-top-color: transparent; border-top-style: solid; border-right-color: transparent; border-left-color: transparent;

column 3:
width:50px; text-align: center; BACKGROUND-COLOR: #424242; color: white; border-right: 1px solid #565656; border-bottom: 1px solid #565656; border-top-color: transparent; border-top-style: solid; border-left-color: transparent;



Post Edited (01-17-06 19:08)
 

tronics

New member
This is a great Mod!
Please Eugenio take a look into this one. For me there is no doubt this one really increases the overall value!

The result of using css styled forms means much more usability for the users plus a more professional look of the forms.

Thanks!
troncis
 

msteitzhamblen

New member
This is really great, but I'm afraid I'm a newbie and had a hard time following the steps between the posts.

Is there anyway you could write a step 1, open file *.* and do...

This may be too much to ask, but you don't know if you don't try!

Thanks,
Mark
 

nassausky

Member
Thanks got it work in version 4.2, took a bit of tweaking.. It's great now to be able to Change independent column width and styles. Thanks for the tips Alpha2zee and Flagio.

That would be fantastic if this change was added to a future version because I intend on using dadabik for quite a long time creating future databases and it would save so much of my time..
 

)-pAchamAma-(

New member
Fine nassauki that you got it working.

Maybe you share your tweaking, I also dried indipendent column width and actually got it working, that the style was added to html, but the column width didn't change.
 

stib

New member
I did a different hack, using the CSS file to set the styles for each column. I only involved changing two lines, and no sql table modifications.

In business_logic.php I modified the line ~3005 from:
$results_table .= "<td class=\"".$td_results_class."\">"; // start the cell

to:
$results_table .= "<td class=\"".$td_results_class." ". $fields_labels_ar[$i]["name_field"] . "\">"; // start the cell

and the same for the the table header in line ~2890, changing:
$results_table .= "<th class=\"results\">";

to
$results_table .= "<th class=\"results " . $fields_labels_ar[$i]["name_field"] . "\">";

note that there is a space between the two classes, so the HTML tag for a table header in a column called "TapeID" would look like <td class="results TapeID">
So what this does is add a CSS style for each column, based on the column name. This is using the fact that you can have multiple CSS classes on a single element (only works on modern browsers).

Then in the styles_screen.css and styles_print.css I can set a unique style for each column. So if I have a column called "TapeID" I can add a css style like so

.tapeID{
width: 20%;
}

*Note* I originally did this and added my column-dependant styles to the end of styles_screen.css and couldn't work out why the style wasn't changing, even though the class was appearing in the HTML. Turns out the last couple of css styles in styles_screen.css don't have the semicolon at the end of the declaration, which breaks the style sheet from there on in:

td.marginvert {
width: 0.5cm
}
td.marginorizz {
height: 1.2cm
}

Should look like
td.marginvert {
width: 0.5cm;
}
td.marginorizz {
height: 1.2cm;
}

If you check the ends of all the lines in styles_screen.css and make sure that each one has a semicolon then you can add your column-specific styles to the end.

Also, to get the width style to work I had to remove "white-space: nowrap;" from the .tr_results_1, .tr_results_2,.tr_highlighted_onmouseover and .tr_highlighted_onclick styles.

Hope this helps someone.



Post Edited (05-03-10 10:31)
 
Top