Somebody help add more column
Somebody help add more column
eduardo12fox
Posts: 17Questions: 0Answers: 0
I need your help, please. The data tables only show five columns y five heads, HOW can I ADD NEW COLUMNS HTML??
Because I should show 8 columns,my code is the next:
<?php echo $Fila['nrocite']; ?>
<?php echo $Fila['ingreso']; ?>
<?php echo $Fila['c_cod_resp']; ?>
<?php echo $Fila['d_fecha_resp']; ?>
<?php echo $Fila['c_cod_cite']; ?>
<?php echo $Fila['dato1']; ?>
<?php echo $Fila['dato2']; ?>
<?php echo $Fila['dato3']; ?>
when I run the script everything is very tight ==> http://www.techall.com.br/Report/themes2.php
staff managed to put it all together now bo
Because I should show 8 columns,my code is the next:
<?php echo $Fila['nrocite']; ?>
<?php echo $Fila['ingreso']; ?>
<?php echo $Fila['c_cod_resp']; ?>
<?php echo $Fila['d_fecha_resp']; ?>
<?php echo $Fila['c_cod_cite']; ?>
<?php echo $Fila['dato1']; ?>
<?php echo $Fila['dato2']; ?>
<?php echo $Fila['dato3']; ?>
when I run the script everything is very tight ==> http://www.techall.com.br/Report/themes2.php
staff managed to put it all together now bo
This discussion has been closed.
Replies
If I understand currectly your problem is how to extend the width of your cols.
If so - it is very simple.
In your thead, go to each of the tags and add the wanted width to then(:
You can either add style="width:'150px';" or add class that will handle the width in a css.
It should look like this (First four th are with width, next four th are with class - choose what is better for you):
[code]
nrocite
ingreso
c_cod_resp
d_fecha_resp
c_cod_cite
dato1
dato2
dato3
<?php echo $Fila['nrocite']; ?>
<?php echo $Fila['ingreso']; ?>
<?php echo $Fila['c_cod_resp']; ?>
<?php echo $Fila['d_fecha_resp']; ?>
<?php echo $Fila['c_cod_cite']; ?>
<?php echo $Fila['dato1']; ?>
<?php echo $Fila['dato2']; ?>
<?php echo $Fila['dato3']; ?>
[/code]
i receive a email from allan redirecting to this discussion.
well the case is that I am in show/hide details record . and I did the example in server-side processing
it doesn`t work out yet. so if you have some code that explain to use an API or the server-side processing.
this is the code a am using now,
[code]
/* Formating function for row details */
var oTable;
function fnFormatDetails ( nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[2]+' '+aData[3]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
return sOut;
}
/* Event handler function */
function fnOpenClose ( oSettings )
{
$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var nTr = this.parentNode.parentNode;
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "../examples_support/details_open.png";
/* fnClose doesn't do anything for server-side processing - do it ourselves :-) */
var nRemove = $(nTr).next()[0];
nRemove.parentNode.removeChild( nRemove );
}
else
{
/* Open this row */
this.src = "../examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );
}
$(document).ready(function() {
oTable = $('#example').dataTable({
"bprocessing":true,
"bserverside":true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource":"server_processing_details_col.php",
"aoColumns": [
{ "sClass": "center", "bSortable": false },
null,
null,
null,
null,
null,
null,
null,
null,
{ "sClass": "center" },
{ "sClass": "center" }
],
/*
* Insert a 'details' column to the table
*/
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";
$('#example thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#example tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
"aaSorting": [[1], 'asc']],
} );
$('#example tbody td img').live( 'click', function () {
var nTr = this.parentNode.parentNode;
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "http://computadorescol.zobyhost.com/DataTables-1.7.5/examples/examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "http://computadorescol.zobyhost.com/DataTables-1.7.5/examples/examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
}
} );
} );
} );
} );
[/code]
my goal in this moment is to show record in a row .
in sAjaxSource :"server-processing-details-col"
I had entering the database data :
Easy set variables
010. */
011.
012. /* Array of database columns which should be read and sent back to DataTables. Use a space where
013. * you want to insert a non-database field (for example a counter or static image)
014. */
015. $aColumns = array( 'engine', 'browser', 'platform', 'version', 'grade' );
016.
017. /* Indexed column (used for fast and accurate table cardinality) */
018. $sIndexColumn = "id";
019.
020. /* DB table to use */
021. $sTable = "ajax";
022.
023. /* Database connection information */
024. $gaSql['user'] = "";
025. $gaSql['password'] = "";
026. $gaSql['db'] = "";
027. $gaSql['server'] = "server remote";
028.
and the result is : only appears the html table without format, nor nothing else.
thanks
karl
I will not write you the code itself (because that means writhing the whole 2 pages) - but I will try to explain you what to do.
If you will remain uncertain about what you need to do - please feel free to ask.
Create a table with n+2 cols (n is the "regular" cells that you want to show).
The Two first cells will be for the '+' button, the second will be for the data to display in the hidden details record.
Inside your declaration - in the second - the to be hidden details recoed - write details .
That way - it will be there - but hidden as needed.
That is all for the display php.
In the php that handles the ajax - you need to return an aaData with the following data:
[
[" ",
"Details will be here ",
"some details",
"some more details"] ,
[" ",
"Details of row 2 will be here ",
"some details2",
"some more details2"]
]
This way - you will use ajax when fetching data, and then - just use it.
Ofcourse that in the despalying php file you will add the javascript function 'handleShowRecord(obj)' - that will handle the UI of hiding/showing the record:
[code]
function fnFormatDetails ( oTable, nTr )
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[1]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:And any further details here (images etc)';
sOut += '';
return sOut;
}
function handleShowRecord(obj)
{
var nTr = $(obj).parentNode.parentNode;
if ( this.src.match('details_close') )
{
/* This row is already open - close it */
this.src = "../examples_support/details_open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "../examples_support/details_close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
}
[/code]
That should work... there is not much to add...
Tell me how it went...
big-deal
http://www.techall.com.br/Report/themes_techall.php
[code]
DT.VENCIMENTO
VALOR DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
TIPO DE CLIENTE
TIPO DE CLIENTE
CATEGORIA DO CLIENTE
<?php
$sql = mysql_query("SELECT * FROM conta");
while($resposta = mysql_fetch_array($sql)){
?>
<?php
$DIA = substr($resposta['VENCIMENTO'],0,4);
$MES = substr($resposta['VENCIMENTO'],5,2);
$ANO = substr($resposta['VENCIMENTO'],8,2);
$junta = $ANO."/".$MES."/".$DIA;
echo $junta; ?>
<?php echo number_format($resposta['VALOR_DOC'], 2, ',', '.'); ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['TIPO_DE_CLIENTE']; ?>
<?php echo $resposta['TIPO_DE_CLIENTE']; ?>
<?php echo $resposta['CATEGORIA_DO_DOC']; ?>
<?php
}
?>
Techall
[/code]
DT.VENCIMENTO
VALOR DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
NUMERO DOC
TIPO DE CLIENTE
TIPO DE CLIENTE
CATEGORIA DO CLIENTE
<?php
$sql = mysql_query("SELECT * FROM conta");
while($resposta = mysql_fetch_array($sql)){
?>
<?php
$DIA = substr($resposta['VENCIMENTO'],0,4);
$MES = substr($resposta['VENCIMENTO'],5,2);
$ANO = substr($resposta['VENCIMENTO'],8,2);
$junta = $ANO."/".$MES."/".$DIA;
echo $junta; ?>
<?php echo number_format($resposta['VALOR_DOC'], 2, ',', '.'); ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['NUMERO_DOC']; ?>
<?php echo $resposta['TIPO_DE_CLIENTE']; ?>
<?php echo $resposta['TIPO_DE_CLIENTE']; ?>
<?php echo $resposta['CATEGORIA_DO_DOC']; ?>
<?php
}
?>
And when I checked
http://www.techall.com.br/Report/themes2.php
I saw that there is no width:150px or anything - so you haven't added that there.
But when I go to
http://www.techall.com.br/Report/themes_techall.php
I see that you have added that - and it looks good - with very nice width.
Maybe you just need to clear your browser's cach?
big-deal
about show/hide record information I read your code, I think that echo is not present because Table ="example" doesn`t receive data.
in other example that works fine the aaData is present , but in thd example I don't see where is the aaData, for that reason I ask about Echo.
Now, in server_processing_details-col.php ( allan) in Datatables1.7.5 /examples/examples_suport the $ echo output is from Filtering and then I imagine I must add..tell me about if this is correct..o r not.. when I could add aaData then echo [ $output ] I think..
I read carefully line by line the code in example Server-side processing and api , and compare it with my code, I have some questions that could give some ideas to clear what I must do :
1. server_processing_details_column.php is the conection to database (mysql) so in the field server[], db[],user[]
I must fill it with data OR
only at the beginning I must add this data and the$gasql [] do the work?
2. in this same file , $output send data to html ?
and then I must change this lines :
$output.=' " '.str_replace(' "' ' , '\"', $aRow['engine'] for the column I desire? instead Engine put Articulo
$output.=' " '.str_replace(' "' ' , '\"', $aRow['browser'] instead Browser put marca and so on.. with others.
3. I made the table well fitted , and I must add a column in html?
4. it appears simply , the code in example is easy to read, but I have tried many ways , I have made changes so I am looking for an easy to do example, because I am confused.
thanks
karl