Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all 1816 articles
Browse latest View live

mRender to alter a cells display color

$
0
0
I would like to change the font color of the data that is being displayed in the table.
I have set an attribute called 'data-changed' and would like mRender to check if it's true or false.
If the attribute is true then I would like to alter the font color.

But I'm stuck. Not sure how to get the cell object so that I can test for the attribute and then how to apply the font color change.

<table>
  <tr id='826'>
    <td id='82' data-changed='false'>Some Data</td>
    <td id='467' data-changed='true'>Some Data</td>
  </tr>
</table>

/* Init dataTable */
var oTable = $( '#tableRates' ).dataTable(
{
  "sPaginationType": "full_numbers",
  "bStateSave": true,
  "aoColumnDefs":
  [
    "mRender": function( data, type, row )
    {
       if ( type === 'display' )
      {
         /* Test cell attribute 'data-changed' */
      }
    }
  ]
} );

Row headers instead of column headers?

Resizing table inside jQueryUI dialog

$
0
0
I want to put a dataTable inside a jQueryUI dialog. This works fine. The dialog is resizable.

Using the "flexible width" example as a guide I trapped the dataTable inside a <div style="width:90%"></div> container. When i resize the datatable, the search bar at the top and the navigation bar at the bottom resize, but the columns themselves to not.

Is what I'm trying to do possible? Or should I fix the width of the table and rely on the dialog's scrollbars?

(I'll try to get a jsFiddle working tomorrow if it would help).

How to set the default value for a dropdown (select)

$
0
0
I am trying to have a dropdown (select) default to the value being returned from the Ajax on the server.

My code is:

            oTable = $('#myDataTable').dataTable({
                "bProcessing": true,
                "bServerSide": true,
                "sAjaxSource": "OCPWebService.asmx/GetData", //PHP Source
                "bJQueryUI": true,
                "bAutoWidth": false,
                "bInfo": true,
                "bPaginate": true,
                "sPaginationType": "full_numbers",
                "bSort": true,
                "bStateSave": true,
                "sDom": '<"add_delete_toolbar">frtip', //creates the toolbar for adding and deleting records
                //"aLengthMenu": [[-1, 10, 25, 50, 100], ["All", 10, 25, 50, 100]], //this sets up the value/name pair in the number of records dropdown.
                "aoColumnDefs": [
                     { "sWidth": "0%", "bSearchable": true, "bVisible": false, "aTargets": [0] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "PDD", "aTargets": [1] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "Office", "aTargets": [2] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "Division", "aTargets": [3] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "Branch", "aTargets": [4] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "Department", "aTargets": [5] },
                     { "sWidth": "20%", "bSearchable": true, "sTitle": "Department Name", "aTargets": [6] },
                     { "sWidth": "7%", "bSearchable": true, "sTitle": "PDD", "aTargets": [7] },
                     { "sWidth": "8%", "bSearchable": true, "sTitle": "Office", "aTargets": [8] },
                     { "sWidth": "8%", "bSearchable": true, "sTitle": "Division", "aTargets": [9] },
                     { "sWidth": "8%", "bSearchable": true, "sTitle": "Branch", "aTargets": [10] },
                     { "sWidth": "8%", "bSearchable": true, "sTitle": "Department", "aTargets": [11] },
                     { "sWidth": "20%", "bSearchable": true, "sTitle": "Department Name", "aTargets": [12] },
                     //{ "sWidth": "5%", "bSearchable": true, "sTitle": "Action", "aTargets": [13] },
                     { fnRender: function (oObj) { return '<select id="ACTION" >' + '<option selected value="N/A"></option>' + '<option value="CHANGE">CHANGE</option>' + '<option value="DELETE">DELETE</option>' + '</select> '; }, "aTargets": [13] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "By", "aTargets": [14] },
                     { "sWidth": "5%", "bSearchable": true, "sTitle": "On", "aTargets": [15] }
                ],
                "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                    /*
                      This function allows you to 'post process' each row after it have been generated for each table draw, 
                      but before it is rendered on screen. This function might be used for setting the row class name etc.
                    */
                    //add the ID field of the record to the TR elements id attribute
                    $(nRow).attr("id", aData[0]);

                    //add the mouseover and mouseout events
                    $(nRow).mouseover(function () {
                        $(this).bind('mouseenter', function () { $(this).addClass('datahighlight'); });
                    })
                    .mouseout(function () {
                        $(this).bind('mouseleave', function () { $(this).removeClass('datahighlight'); });
                    });

                    $(nRow).children().each(function (index, td) {
                        //add the class 'edit' to the NEW columns so that jEdit can be used
                        if (index == 12) {
                            //add the id attrib of red
                            $(this).addClass('edit_select');
                        }
                    });
                },
                "fnDrawCall": function(oSettings){
                    $('.edit_select').editable("OCPWebService.asmx/UpdateData", {
                        indicator : '<img src="img/indicator.gif">',
                        data   : "{'Lorem ipsum':'Lorem ipsum','Ipsum dolor':'Ipsum dolor','Dolor sit':'Dolor sit'}",
                        type   : "select",
                        submit : "OK",
                        style  : "inherit",
                        submitdata : function() {
                            return {id : 2};
                        }
                    });
                },
                "fnServerData": function (sSource, aoData, fnCallback) {
                    LoadData(sSource, aoData, fnCallback);
                }
            }); //end of table definition

            $(window).bind('resize', function () {
                oTable.fnAdjustColumnSizing();
            });

I would like column 13 to show the SELECT and have the default value equal to the value being returned.

Any help is greatly appreciated.

fnDeleteRow doest not delete When using ServerCall to load Data

$
0
0
I modified the dataTable to load using a fnServerData. But fnDeleteRow doesnot deleting the rows now.

  


/* Get the rows which are currently selected */
function fnGetSelected( oTableLocal )
{
    return oTableLocal.$('tbody tr.row_selected');
}

//DataTable 

 oTable = $('#table_data').dataTable({
			"bProcessing": true,
			"bServerSide": true,
			"sAjaxSource": woocommerce_writepanel_params.ajax_url,
			"fnServerData": fnDataTablesPipeline,	  
			"bAutoWidth": false	
});

//Performing Ajax function to delete the selected rows
     var anSelected = fnGetSelected( oTable );
       jQuery.ajax({
		type: "POST",
		data: post_data,	
		url: 'ajax.php',
		success: function(response) {
				$('#variable_product_options').stop(true).css('opacity', '1').unblock();
					$.each(anSelected,function(i,v) {
					oTable.fnDeleteRow(anSelected[i]);
				});
			}
		});

Disable DataTables procesing on large datasets

$
0
0
I deployed DataTables on an existing application with hundreds of reports and pages.
These pages use different datasources and inputs, so switching all of them to server side rendering takes (a lot of) time.

Is it possible to use iTotalRecords to "disable" DataTables if it exceeds a certain value and just render the table as it's source HTML, without the DataTables options on them until I can change the page to using ssr?

I cannot add an example as it's an internal application with confidential data, yet for the concept of the question I don't think it's mandatory?

unable to display footer and pagination buttons

$
0
0
Hi,

I am not able to display Footer in DataTable
Also my pagination button do not display correctly and they tend to merge with the last row of the table.
Any guess.???
<div id="tableDataDiv">
	<table id="tableData">
	<thead>
	</thead>
	<tbody>
	</tbody>
	<tfoot>
	Total
	</tfoot>
	</table>
	</div>
	<footer class="module-footer"> </footer>

function createTable(tblName, filterParams) {
		oTable =null;
		oTable = $("#tableData").dataTable({
		"sAjaxSource" : "/getTableData/"+tblName,
		"fnServerParams": function (aoData) {
			aoData.push({name: "filterParamList", value: filterParams});
	    	},
		"bProcessing": true,
		"iDisplayLength" : 10,
		"bJQueryUI": true,        
		"sPaginationType": "full_numbers",
		"aoColumns" : [ {
			"sTitle" : "SSO ID",
			"mData" : "sso_id",
			"aTargets" : [ 0 ],
			"bSortable" : true
		}, {
			"sTitle" : "Shop Name",
			"mData" : "shop_name",
			"aTargets" : [ 1 ],
			"bSortable" : true,
			"sClass" : "dataTable_editable"
		}, {
			"sTitle" : "User Type",
			"mData" : "user_type",
			"aTargets" : [ 2 ],
			"bSortable" : true,
			"sClass" : "dataTable_editable"
		}]
		});
	}

Scrolling position resets on tab change in Firefox

$
0
0
Hi Allan,

I am using server side datatable 1.9 with scroller inside a tab. Using the scroller, I scroll down to fetch next set of rows from server. When I navigate to another tab and navigate back to this tab, the scroller position goes back to the top. How do I keep the same position on tab change also?

multiple filtering with submit button

$
0
0
Hello,

I'm new with datatable. I've already checked a lot of post but not found what I need. I currently have multiple text boxes and one datatable.
I need to send to server side the values which are in my textboxes to filter the results. Currently I'm using the "aoData.push":


"fnServerData": function (sSource, aoData, fnCallback) {
            /* Add some extra data to the sender */
            aoData.push({ "name": "CompanyName", "value": $('#myCustomTSearchextFieldCompanyName').val() }, { "name": "Address", "value": $('#myCustomTSearchextFieldAddress').val() });
            $.getJSON(sSource, aoData, function (json) {

                /* Do whatever additional processing you want on the callback, then tell DataTables */
                fnCallback(json);
            });
        }


As "$('#myCustomTSearchextFieldCompanyName').val()" is used to filter the first column and "$('#myCustomTSearchextFieldAddress').val()" the second column, I think it's better to send the parameters via sSearch_0 and sSearch_1.

But I've no idea how can I set the "sSearch_x" on the submit click.

I've also already checked the "columnFilter" add-in but as I've a specific html for the responsive design I don't want to change my code again.

Thank you.

bad look & feel

$
0
0
Hi just download the DataTAble 1.9


tries to make a basic demo:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core&quot; prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo</title>

<link href="resources/css/demo_table.css" rel="stylesheet" type="text/css" />




<script type="text/javascript" charset="utf-8" src="resources/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="resources/js/jquery.dataTables.js"></script>

<script type="text/javascript">
$(document).ready( function () {
$('#table_id').dataTable();
} );
</script>
</head>


<body>


<table id="table_id">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>


</body>
</html>

But that's the result :-(

https://scontent-a-ams.xx.fbcdn.net/hphotos-frc3/t1.0-9/1795493_1374615349481499_1647144929_n.jpg

And this the console messages. Thanks.

23:06:38.708 Propiedad desconocida 'zoom'. Declaración rechazada. demo_table.css:36
23:06:38.709 Se esperaba una declaración, pero se encontró '*'. Ignorado hasta la siguiente declaración. demo_table.css:82
23:06:38.709 Se esperaba una declaración, pero se encontró '*'. Ignorado hasta la siguiente declaración. demo_table.css:157
23:06:38.709 Se esperaba una declaración, pero se encontró '*'. Ignorado hasta la siguiente declaración. demo_table.css:268
23:06:38.709 Propiedad desconocida '-moz-border-radius'. Declaración rechazada. demo_table.css:334
23:06:38.709 Se esperaba una declaración, pero se encontró '*'. Ignorado hasta la siguiente declaración.

DEBUG:

Error al interpretar el valor para 'background'. Declaración rechazada. DT_Debug.css:13
23:11:15.408 Error al interpretar el valor para 'background'. Declaración rechazada. DT_Debug.css:14
23:11:15.408 Error al interpretar el valor para 'background'. Declaración rechazada. DT_Debug.css:15
23:11:15.408 Error al interpretar el valor para 'background'. Declaración rechazada. DT_Debug.css:16
23:11:15.408 Se esperaba un color, pero se encontró 'top'. Error al interpretar el valor para 'background'. Declaración rechazada. DT_Debug.css:17
23:11:15.408 Se esperaba 'none' o una URL, pero se encontró 'progid'. Error al interpretar el valor para 'filter'. Declaración rechazada. DT_Debug.css:18
23:11:15.408 Se esperaba una declaración, pero se encontró '*'. Ignorado hasta la siguiente declaración.

Datatables IE8 and sort indicator

$
0
0
Hi,

I have a simple test page shown below (I would have posted a link to a test page, but none of the online javascript playgrounds I tried (jsfiddle, jsbin etc) seemed to support IE8).

<!DOCTYPE html>
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;
        </script>
        <script src="http://datatables.net/download/build/nightly/jquery.dataTables.js"&gt;
        </script>
        <meta charset=utf-8 />
        <title>DataTables - JS Bin</title>
        <style type="text/css">
            table.dataTable .sorting_asc {
                background: red;
            }
            
            table.dataTable .sorting_desc {
                background: blue;
            }
            
            table.dataTable {
                margin: 0 auto;
                clear: both;
                width: 100%;
                border-collapse: collapse;
                border: 1px solid #CBCBCB;
                font-size: 8pt;
            }
            
            table.dataTable thead tr {
                background: #D8D8DA;
                font-weight: bold;
                text-decoration: none;
                color: #000; /* header text */
                border: none;
                white-space: nowrap;
                margin: 3px 0;
                cursor: pointer;
                padding: 0 18px 0 10px;
            }
            
            table.dataTable thead th {
                border-bottom: 1px solid #CBCBCB;
                text-align: left; /* For IE8 this needs to be specified on the th instead of the tr. See http://stackoverflow.com/questions/11321065/th-text-align-compatibility */
            }
            
            table.dataTable td, table.dataTable thead th {
                border-right: 1px solid #CBCBCB;
                padding: 4px 20px 4px 5px;
            }
            
            table.dataTable .even {
                background-color: #F0F2F3;
            }
            
            table.dataTable .odd {
                background-color: #D8DCDF;
            }
        </style>
    </head>
    <body>
        <table id="TestTable" width="80%">
            <TR>
                <TD width="250">
                    Banana
                </TD>
                <TD>
                    1
                </TD>
            </TR>
            <TR>
                <TD width="250">
                    Apple
                </TD>
                <TD>
                    2
                </TD>
            </TR>
            <TR>
                <TD width="250">
                    Pear
                </TD>
                <TD>
                    3
                </TD>
            </TR>
        </table>
        <SCRIPT>
            var TestTableObject = {
                "columnDefs": [{
                    "label": "Fruit",
                    "hidden": false
                }, {
                    "label": "Test",
                    "hidden": true
                }],
                "tableID": "TestTable"
            };
            jQuery(document).ready(function(){
                createNewDatatable(TestTableObject);
            });
            
            function createNewDatatable(enhancedTableNamespace, containerEl){
                var columnInfo = [];
                var currItem;
                var newItem;
                var datatableObject = jQuery(document.getElementById(enhancedTableNamespace.tableID));
                var lastItem;
                
                for (var index = 0; index <= enhancedTableNamespace.columnDefs.length - 1; index++) {
                    currItem = enhancedTableNamespace.columnDefs[index];
                    newItem = {};
                    
                    if (currItem.label) {
                        newItem.sTitle = currItem.label;
                    }
                    
                    if (currItem.hidden) {
                        newItem.bVisible = false;
                    }
                    
                    columnInfo.push(newItem);
                }
                
                datatableObject.dataTable({
                    "sDom": "rt",
                    "iDisplayLength": -1,
                    "aoColumns": columnInfo,
                    "aaSorting": [],
                    "bSortClasses": false
                });
            }
        </SCRIPT>
    </body>
</html>

This test page has 2 columns, one of which is not visible. When I try and sort the fruit column, the heading background colour changes from blue to red in all other browsers except for IE8. In IE8, the column sorts but the heading background colour does not change.

If I remove the hidden column from the html markup, then the fruit column sorts properly and the heading background colour does change.

Does anyone know why this may be the case?

Thanks for your help.

Cheers,
Kaye

Database fields and aoColumns order

$
0
0
Hi,

Many of my database queries return fields not in the order as it is being shown in grid. Since this is LIVE application and right now, we are changing our existing list using DataTable, we are finding it difficult to order the database fields and actual order required to be shown in grid.

Is there any option to write aoColumns array irrespective of the database fields order containing in the aaData array?

Point is we don't want to use aTargets option of aoColumnDefs as the fields and its order in the database query can be changed now and then.

Regards,
Prathap.

Filter records based on column data

$
0
0
My data array contains boolean (yes/no), tinyint (0/1/2) values. In fnCreatedRow function, i change it to respective text to display like below:

"fnCreatedRow": function (nRow, aData, iDataIndex) {
                (aData[3] == 'Yes') ? $(nRow.cells[2]).html("Scheduled") : $(nRow.cells[2]).html("Manual");            
            }

Now when i do search with
Schedule
, i am not getting any data. But if i search with
Yes
, i will get the respective row.

Can someone please give me a solution to search on the column data rather than on data array?

Regards,
Prathap.

Can't change column values after sorting with JQuery UI (sortable)

$
0
0
I'm using sortable in JQuery UI with my DataTable but when I drag&drop a row it's not possible to edit it any more. All other rows still works but it's like the moved row is dead.

I'm trying to update the column with my row count after every sort (listener on the stop event). Anyone that knows the problem or a solution that works?

Blanks in date column causes string sort - continued

$
0
0
Referring to http://www.datatables.net/forums/discussion/4904/blanks-in-the-date-column-causes-string-sort/p1,

when I use a custom date sorting function via a type detection (dynamic columns cannot set predefined type), the sorting function is still switching to string, when there is no value in a table cell, yet there are some HTML tags in the cell.

ie
 <td><center></center></td>

The solution in the original case consists of setting the detected type to undefined for blank cells, is this something I can do from my type detection function as well? I tried to return "undefined", yet that does not work.

		var sInput = sData.replace(/<[^>]+>/g,'');
		if (sInput.length == 0) {
			return undefined;
		}

Is there a way to tell from the type detection function to stop detection on this cell and move on to the next, hence preventing a string match caused by the html tags?

Functions fnDraw and fnReloadAjax works partially - Not drawing/update view

$
0
0
Hi, dear friends. I'm trying to update my table every time a button is clicked. For this, i googled and the sources showed me two functions: fnDraw and fnReloadAjax. I have tried both of them, and the response from the server was ok, just like the first ajax call. It was the first call (GET) when the page loaded:


http://sigac/financeiro/arquivosRemessas?sEcho=1&iColumns=2&sColumns=&iDisplayStart=0&iDisplayLength=2&mDataProp_0=0&mDataProp_1=1&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&_=1394716175634


And the response:
{"sEcho":1,"iTotalRecords":"2","iTotalDisplayRecords":"2","aaData":[["dmy","34"],["2014-03-12 00:00:00","34"]]}

Then purposely i've changed my database to obtain a different query result. When the button is clicked the ajax request is done and it returns the right data:

The request:
http://sigac/financeiro/arquivosRemessas?sEcho=2&iColumns=2&sColumns=&iDisplayStart=0&iDisplayLength=2&mDataProp_0=0&mDataProp_1=1&sSearch=&bRegex=false&sSearch_0=&bRegex_0=false&bSearchable_0=true&sSearch_1=&bRegex_1=false&bSearchable_1=true&iSortCol_0=0&sSortDir_0=asc&iSortingCols=1&bSortable_0=true&bSortable_1=true&_=1394716175635

The response:
{"sEcho":1,"iTotalRecords":"1","iTotalDisplayRecords":"1","aaData":[["dmy","34"]]}

But my table does not redraw!
Below is my piece of code:
var oTable = $('#sample_1').dataTable({

        "bProcessing": false,
        "bServerSide": true,
        "sServerMethod": "GET",
        "sAjaxSource": "http://sigac/financeiro/arquivosRemessas",
        "iDisplayLength": 2,
        "aaSorting": [[0, 'asc']],
        "aLengthMenu": [
            [2, 4, 6, -1],
            [2, 4, 6, "Todos"]
        ],
            
    });

 $('#btn-create-remessa').on('click',function(){    	
        //oTable.fnReloadAjax();
        oTable.fnDraw();
    })
I do not know what else to do. Can anyone help me?
Thanks in advance!

fnReloadAjax always show ten data, bLengthChange not working and dataTable pagging not show

$
0
0
Hai advance, I got problem when use fnReloadAjax,
- my goal is initialization dataTable without load data at first load page, and data will load after click trigger (search button).
- my problem is data always show ten row, bLengthChange not working and dataTable pagging not show. this my DOM information:

_bInitComplete -> true
_iDisplayEnd -> 10
_iDisplayLength -> 50
_iDisplayStart -> 0
_iRecordsDisplay -> 0
_iRecordTotal -> 0

this my code:

$(document).ready(function() {
	
	var tblKkm = kkmDataTable();

	searchButton(tblKkm);
});

/**
 * function search button
 * 
 */
function searchButton(oTable) {
	$("#search-kkm").bind("click", function() {
		var obj = {};
		obj.tahun_id = $('select[name="tahun-ajaran"]').val();
		obj.tingkat = $('select[name="tingkat"]').val();
		obj.semester = $('select[name="semester"]').val();
		
		//...encode URL
		var stringifyObj = encodeURIComponent(JSON.stringify(obj));

		oTable.fnReloadAjax('kriteria_ketuntasan_minimum/populate_pelajaran_kkm/?q=' + stringifyObj, null, true);
	});
}

/**
 * function create table dataTable
 */
function kkmDataTable() {
	var tblKKM = $("#tbl-kkm").dataTable({
		"fnDrawCallback": function() {
			addNilaiKkm(this);
		},
		"bLengthChange": false,
		"bSort": false,
		"bFilter": true,
		"bProcessing": true,
 		"bStateSave": true,
 		"iDisplayLength": <?php echo ($this->settings_lib->item('site.list_limit')) ? $this->settings_lib->item('site.list_limit') : 15; ?>,
 		"sPaginationType": 'bootstrap',
		"aoColumns": [
 			{ 'sTitle' : 'pelajaran id', 'bVisible': false },
 			{ 'sTitle' : 'tahun id', 'bVisible': false },
 			{ 'sTitle' : 'Pelajaran', 'sWidth':'40%' },
 			{ 'sTitle' : 'Nilai KKM', 'sWidth':'10%', 'sClass': ' center' },
 			{ 'sTitle' : 'Terbilang' },
 		]
	});
	return tblKKM;
}


if advance have different way for my problem please show me the way.
thanks.

Dialog bos in Datatable

$
0
0
I need to display whole message in a dialog box when the link inside the table column is clicked.But if i use jquery.ui.dialog.js then datatable.js is not working and vice versa. so how can i solve this.

Jeditable - Edit records inline

$
0
0
Hi,
I'm using Jeditable for modify my DataTables: I use it for show ed edit any parameters of my configuration (host, username, password, etc...)

I have an exigence: I only wish that the record field is shown with asterisks, and an input type = "password", for security is best that the password not is showing.

It's possibile?

Thanks.

Loading and next works fine - crashes on search

$
0
0
My first load is fine and I can show next and previous set but when I search, the php search page crashes (500 Internal Server Error).
I have this in my server_processing.php
$aColumns = array( 'fnavn','firma','kundenr','postnr','sted','kontakt','mobil','ansvarlig' );

Wonder if it has to do with the "fnavn" field. This is a subselect and not a field in the MySQL DB. This is MySQL. I am searching the table "montor" and fetching the text "fylke" from the table "fylke" where the "m.fylke" number equals the field "m.fylke_id"

$sWhere = "WHERE m.fylke = f.fylke_id";

	$sQuery = "SELECT SQL_CALC_FOUND_ROWS f.fylke as fnavn, m.fylke, m.firma, m.kundenr, m.postnr, m.sted, m.kontakt, m.mobil, m.ansvarlig
		FROM   montor AS m, fylke AS f 
		$sWhere
		$sOrder
		$sLimit
		";
My javascript:
......
"aoColumns": [
				        { "mData": "fnavn" },
        				{ "mData": "firma" },
				        { "mData": "kundenr" },
				        { "mData": "postnr" },
				        { "mData": "sted" },
				        { "mData": "kontakt" },
				        { "mData": "mobil" },
				        { "mData": "ansvarlig" }
				    ]

I need the field "fnavn" - is it correct to put it in the $acolumns array? If I remove that field from the javascript and PHP file I get no errors. So the problem seems to be there. But what is the correct way to get that value and not search on it, since the field does not exist in the table itself?
Viewing all 1816 articles
Browse latest View live