Need help in removing sort arrows (asc and desc) on data tables header row, then when the user click the header column an ascending arrow will appear and of course data will be sorted in asc order
$("#MyDataTable").dataTable({
"aoColumns": [{"bSortable": false}, null]
});
"aoColumnDefs": [ { "bSortable": false, "aTargets": [ 1, 3 ] } ]
To remove sort arrows from the second and the fourth columns.
Reference: http://wordpress.org/support/topic/plugin-wp-table-reloaded-removing-the-updown-sorting-arrows-on-specific-columns
> This is Best Answer for removing sort arrow
>
>
> $('#itjbg-table').dataTable({
> 'columnDefs': [{ 'orderable': false, 'targets': 0 }], // hide sort icon on header of first column
> 'aaSorting': [[1, 'asc']] // start to sort data in second column });
Within dataTables.Bootstrap.css are three classes that add these sort images. They are sorting, sorting_asc, and sorting_desc. During the DataTable initialization disable sorting as first stated by "satej kumar sahu" via the bSortable : false. Then do a removeClass for the header, my header had an id="division". Then create a click event for the header, same id, to do a another removeClass to preserve any other functionality, in my case to preserve the column dropdown via columnFilter. Review attached code.
$('#example').dataTable({
"order": [[1, "asc"], [7, "asc"], [4, "asc"]],
"aoColumnDefs": [{ "bSortable": false, "aTargets": [1]}],
"columns":[null, {className: ""}, null, null, null , null, null, null, null, null]
}).columnFilter({
sPlaceHolder: "head:after",
aoColumns: [null, { type: "select" }, null,
null, null, null, null, null, null, null]
});
$('#division').removeClass('sorting sorting_asc sorting_desc');
$('#division').click(function () {
$('#division').removeClass('sorting sorting_asc sorting_desc');
});
table.dataTable thead .sorting { background: url('../images/sort_both.png') no-repeat center right; }
table.dataTable thead .sorting_asc { background: url('../images/sort_asc.png') no-repeat center right; }
table.dataTable thead .sorting_desc { background: url('../images/sort_desc.png') no-repeat center right; }
<thead>
<tr class="info">
<th scope="col">Title</th>
<th id="division" scope="col">Division</th>
<th scope="col">Attendee</th>
<th scope="col">Supervisor</th>
<th scope="col">Start Date</th>
<th scope="col">End Date</th>
<th scope="col">Duration(hr)</th>
<th scope="col">Fee</th>
<th scope="col">Status</th>
<th scope="col">Comments</th>
</tr>
</thead>
HOW TO REMOVE DATATABLES GLYPHCONS / ICONS !!
Use this following code on your css file :
if you see the column glyph-cons on Table header use this !!
th.sorting_asc::after, th.sorting_desc::after { content:"" !important; }
if you see the glyph-cons on Table data use this !!
td.sorting_asc::after, td.sorting_desc::after { content:"" !important; }
in short change "this" part, where the class="sorting_desc/asc" situated.
"this".sorting_asc::after, "this".sorting_desc::after { content:"" !important; }
what I got from your question is that you want to remove initial sort from the table and only sort when the user clicks on a column header. you can do that using the following code:
$(document).ready( function() {
$('#example').dataTable( {
"aaSorting": []
} );
} );
http://datatables.net/ref#aaSorting
Related
I have a dynamically filled datatable with fixed columns and scrollX enabled:
$('#products').DataTable({
"data": formattedData,
"scrollX": true,
"fixedColumns":{ "leftColumns": 0, "rightColumns": 1 }
});
The problem is, I need the columns to stop automatically calculating their width. Even if I try to force them on initialization...
$('#products').DataTable({
"order": [[ 0, "asc" ]],
"columnDefs": [
{ "title": "Name", "targets": 0, "width": "350px" },
{ "title": "Code", "targets": 1 },
{ "title": "Regular code", "targets": 2, "width": "500px" },
{ "title": "Special code", "targets": 3, "width": "300px" }
]
});
... if scrollX is enabled, the scrolling is enabled just if the columns are too small. And I want the scrolling enaled always, and the columns not changing their width.
Any idea about how to force the column width?
The same question was asked here but has no answer: https://datatables.net/forums/discussion/31403/scrollx-not-work-with-fixed-column-width
First disable autoWidth -> https://datatables.net/reference/option/autoWidth
In my humble opinion columns.width are useless to anything than relative percentages. Define minimum column widths in CSS instead
#products td:nth-child(1) { min-width: 350px; }
#products td:nth-child(3) { min-width: 500px; }
#products td:nth-child(4) { min-width: 300px; }
http://jsfiddle.net/f8uw6rLy/
I need to add a background color that should be like this
I think that the only solution would be to add a span inside the th container like this:
<th class="sorting_asc" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Companies: activate to sort column descending" aria-sort="ascending">
<span>Companies</span>
</th>
Unfortunatly I have no idea of how to add the spans
Add this bgcolor attribute in <th> like this:
<th bgcolor="#FF0000">Companies</th>
You can include <span>'s in the columns / columnDefs title option :
$('#example').DataTable( {
columns: [
{ data: "name", title: '<span class="red">Name</span>' },
{ data: "position", title: '<span class="blue">Position</span>' },
//etc
]
})
examples -> http://jsfiddle.net/z1afh42j/
I'm trying to specify a fixed width for a few columns in a jQuery datatable. I've attempted to accomplish this via the column definitions specified in the datatables documentation, but the column and column header still get auto-sized.
Here's the jsFiddle I've been working with: jsFiddle
JavaScript:
var table = $('#example2').DataTable({
"tabIndex": 8,
"dom": '<"fcstTableWrapper"t>lp',
"bFilter": false,
"bAutoWidth": false,
"data": [],
"columnDefs": [
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": '',
"targets": 0
},
{
"targets": 1},
{
"targets": 2,
"width": "60px"},
{
"targets": 3,
"width": "1100px"},
{
"targets": 4},
{
"targets": "dlySlsFcstDay"},
{
"targets": "dlySlsFcstWkTtl",
"width": "60px"}
],
"order": [
[1, 'asc']
]
});
HTML:
<div class="forecastTableDiv">
<table id="example2" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th colspan="5"></th>
<th class="slsFiscalWk" colspan="8">201424</th>
<th class="slsFiscalWk" colspan="8">201425</th>
<th class="slsFiscalWk" colspan="8">201426</th>
<th class="slsFiscalWk" colspan="8">201427</th>
</tr>
<tr>
<!--<th></th>-->
<!--<th>Vendor</th>-->
<!--<th>Origin ID</th>-->
<!--<th>Destination</th>-->
<!--<th>Vendor Part Nbr</th>-->
<!--<th>SKU</th>-->
<!--<th>Mon</th>-->
<!--<th>Tue</th>-->
<!--<th>Wed</th>-->
<!--<th>Thu</th>-->
<!--<th>Fri</th>-->
<!--<th>Week Ttl</th>-->
<th></th>
<th>Vendor</th>
<th>Origin ID</th>
<th style="width: 200px">Vendor Part Nbr</th>
<th>SKU</th>
<!-- First week -->
<th class="dlySlsFcstDay" >Mon</th>
<th class="dlySlsFcstDay" >Tue</th>
<th class="dlySlsFcstDay" >Wed</th>
<th class="dlySlsFcstDay" >Thu</th>
<th class="dlySlsFcstDay" >Fri</th>
<th class="dlySlsFcstDay" >Sat</th>
<th class="dlySlsFcstDay" >Sun</th>
<th class="dlySlsFcstWkTtl" >Week Ttl</th>
<!-- Second week -->
<th class="dlySlsFcstDay" >Mon</th>
<th class="dlySlsFcstDay" >Tue</th>
<th class="dlySlsFcstDay" >Wed</th>
<th class="dlySlsFcstDay" >Thu</th>
<th class="dlySlsFcstDay" >Fri</th>
<th class="dlySlsFcstDay" >Sat</th>
<th class="dlySlsFcstDay" >Sun</th>
<th class="dlySlsFcstWkTtl" >Week Ttl</th>
<!-- Third week -->
<th class="dlySlsFcstDay" >Mon</th>
<th class="dlySlsFcstDay" >Tue</th>
<th class="dlySlsFcstDay" >Wed</th>
<th class="dlySlsFcstDay" >Thu</th>
<th class="dlySlsFcstDay" >Fri</th>
<th class="dlySlsFcstDay" >Sat</th>
<th class="dlySlsFcstDay" >Sun</th>
<th class="dlySlsFcstWkTtl" >Week Ttl</th>
<!-- Fourth and final week -->
<th class="dlySlsFcstDay" >Mon</th>
<th class="dlySlsFcstDay" >Tue</th>
<th class="dlySlsFcstDay" >Wed</th>
<th class="dlySlsFcstDay" >Thu</th>
<th class="dlySlsFcstDay" >Fri</th>
<th class="dlySlsFcstDay" >Sat</th>
<th class="dlySlsFcstDay" >Sun</th>
<th class="dlySlsFcstWkTtl" >Week Ttl</th>
</tr>
</thead>
<tfoot>
</table>
</div>
When I inspect the live code, I can see that the width I'm specifying in the column definition is getting added to the column as a style attribute, but it doesn't match the actual width of the column.
This is not a DataTables issue. See how column widths are determined. Based on this algorithm I see the following two solutions.
Solution 1
Calculate yourself the table width and set it accordingly.
#example {
width: 3562px;
}
See live example here: http://jsfiddle.net/cdog/jsf6cg6L/.
Solution 2
Set the minimum content width (MCW) of each cell and let the user agent to determine the column widths.
To do this, add classes to the target columns to be able to style them:
var table = $('#example').DataTable({
tabIndex: 8,
dom: '<"fcstTableWrapper"t>lp',
bFilter: false,
bAutoWidth: false,
data: [],
columnDefs: [{
class: 'details-control',
orderable: false,
data: null,
defaultContent: '',
targets: 0
}, {
targets: 1
}, {
class: 'col-2',
targets: 2
}, {
class: 'col-3',
targets: 3
}, {
targets: 4
}, {
targets: 'dlySlsFcstDay'
}, {
targets: 'dlySlsFcstWkTtl'
}],
order: [[1, 'asc']]
});
Then set the desired value of the minimum width property for each class:
.col-2,
.dlySlsFcstWkTtl {
min-width: 60px;
}
.col-3 {
min-width: 1100px;
}
See live example here: http://jsfiddle.net/cdog/hag7Lpm5/.
Here is a code sample (fixed the column width for 4 column table):
set autoWidth: false;
set px values to first 3 columns;
important: check if the table width is a bit more than 3 columns + final one;
adjust the table width and 4th column.
$('#example').DataTable({ //four column table
autoWidth: false, //step 1
columnDefs: [
{ width: '300px', targets: 0 }, //step 2, column 1 out of 4
{ width: '300px', targets: 1 }, //step 2, column 2 out of 4
{ width: '300px', targets: 2 } //step 2, column 3 out of 4
]
});
Set table width, 4*300px:
#example { width: 1200px };
As result you will see 1st 3 columns with 300px width and the final one will be flexible and about 150px (which requires additional adjusting).
Last but not least: fixed column size 300px will not prevent you from the case when cell contains a too long (> 300px without spaces) word. So you have to keep in mind that all words must be less than the fixed side of your column.
for the <table> tag or its css class or css id add the following style:
`table{
margin: 0 auto;
width: 100%;
clear: both;
border-collapse: collapse;
table-layout: fixed;
word-wrap:break-word;
}`
Setting a fixed column width can be a real pain. The following solution works nicely.
{ width: 250, targets: 1, class: "someClass",
render : function ( data, type, row ) {
if ( type === 'display' ) {
return `<div style="width:250px"> ${data} </div>`;
}
return data;
}
}
I'm using Custom HTML Rally Grid to develop a table that must return some statistics. My JavaScript is being called at the head of my HTML and i'm creating a table in the body tag. So, my JavaScript is setting values in the table using the fields ids. The problem is: the table is being loaded but when the Rally.launchApp method runs, the table disappears. Curiously, if i check the font-code, the table still there.
<!DOCTYPE html>
<html>
<head>
<title>Grid With Freeform Data Example</title>
<script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
var firstMetricResult;
var secondMetricResult;
var firstMetricName = "% of user stories assigned story points";
var secondMetricName = "Average story points per user story ";
var currentProjectName = Rally.environment.getContext().getProject().Name;
var currentProjectNameID = document.getElementById("currentProjectNameID");
currentProjectNameID.value = currentProjectName;
var benchmark = 20;
var storiesQuery = Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
fetch: ['PlanEstimate', 'LastUpdateDate'],
filters: [
{property: 'ScheduleState',
operator: '=',
value: 'Accepted'},
{property: 'DirectChildrenCount',
operator: '=',
value: '0'},
{property: 'AcceptedDate',
operator: '<',
value: 'LastMonth'},
{property: "Iteration.Name",
operator: "!contains",
value: "hardening"},
{property: "Iteration.Name",
operator: "!contains",
value: "regression"},
{property: "Iteration.Name",
operator: "!contains",
value: "stabilization"}
]
});
storiesQuery.load({
callback: function(records, operation) {
if(operation.wasSuccessful()) {
var estimatedStoriesCount = 0;
Ext.Array.each(records, function(record){
if (record.get('PlanEstimate') != null){
estimatedStoriesCount++;
}
});
var storiesCount = records.length;
firstMetricResult = (estimatedStoriesCount*100)/storiesCount;
alert(firstMetricResult);
}
}
});
var estimatedStoriesQuery = Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
fetch: ['PlanEstimate', 'LastUpdateDate'],
filters: [
{property: 'PlanEstimate',
operator: '!=',
value: 'null'},
{property: 'ScheduleState',
operator: '=',
value: 'Accepted'},
{property: 'DirectChildrenCount',
operator: '=',
value: '0'},
{property: 'AcceptedDate',
operator: '<',
value: 'LastMonth'}
]
});
estimatedStoriesQuery.load({
callback: function(records, operation) {
if(operation.wasSuccessful()) {
var astoriesCount = records.length;
var storiesPointsSum = 0;
Ext.Array.each(records, function(record){
storiesPointsSum += record.get('PlanEstimate');
});
secondMetricResult = storiesPointsSum/astoriesCount;
alert(secondMetricResult);
}
}
});
}
});
Rally.launchApp('CustomApp', {
name: 'Grid With Freeform Data Example'
});
});
</script>
<style type="text/css">
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
</style>
</head>
<body>
<table border=1 class='gridtable' id="tab1">
<tr>
<th> Team </th>
<td><b>All prior periods</b></td>
<td><b>All prior periods</b></td>
</tr>
<tr>
<td id="currentProjectNameID">
</td>
</tr></table>
</body>
</html>
I decided to use this simple HTML table because i want to have the power to edit the CSS.
Thanks.
The above answer is correct. Generally when working with apps (and ExtJS) most content is created through javascript rather than literally declared dom.
Check out this guide for a little more info on working with content in apps: https://developer.help.rallydev.com/apps/2.0rc1/doc/#!/guide/add_content
Something like this should work though if you're still sold on the manual dom manipulation:
launch: function() {
this.add({
xtype: 'component',
html: [
'<table border=1 class="gridtable" id="tab1">',
'<tr>',
'<th> Team </th>',
'<td><b>All prior periods</b></td>',
'<td><b>All prior periods</b></td>',
'</tr>',
'<tr>',
'<td id="currentProjectNameID"></td>',
'</tr>',
'</table>'
].join('')
});
},
afterRender: function() {
this.callParent(arguments);
//the rest of your code that used to be in launch here
}
Then you should be able to look up the elements by id and manipulate them as you'd like.
You would still be able to modify the CSS if you used an Ext grid or a rallygrid - besides using normal CSS selectors to style the grid, you also have access to certain properties when creating the grid - the renderer function for a column takes meta as its second parameter, which has an attribute called tdCls which you can use to style cells in that column. For example:
.green > .x-grid-cell-inner {
border : 1px solid #afd3b6;
background : #c6efce;
background : -moz-linear-gradient(top, #c6efce 0%, #afd3b6 100%);
background : -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c6efce), color-stop(100%,#afd3b6));
background : -webkit-linear-gradient(top, #c6efce 0%,#afd3b6 100%);
background : -o-linear-gradient(top, #c6efce 0%,#afd3b6 100%);
background : -ms-linear-gradient(top, #c6efce 0%,#afd3b6 100%);
background : linear-gradient(to bottom, #c6efce 0%,#afd3b6 100%);
filter : progid:DXImageTransform.Microsoft.gradient( startColorstr='#c6efce', endColorstr='#afd3b6',GradientType=0 );
}
{
text : 'State',
dataIndex : 'c_WINListState',
editor : 'stateeditor',
renderer : function(value, meta, record) {
if (value === 'At Risk') {
meta.tdCls = 'yellow';
} else if (value === 'Off Track') {
meta.tdCls = 'red';
} else if (value === 'On Track') {
meta.tdCls = 'green';
} else if (value === 'Complete') {
meta.tdCls = 'grey';
}
return value;
}
},
I would recommend using the built in functionality.
That being said, I think this is the reason for the built in functionality - if you look at the SDK, the launch app function states:
Create and execute the specified app. Ensures all required components have been loaded and the DOM is ready before app code begins executing. As soon as all required dependencies have been loaded the launch method will be called.
I've already searched for the answer, and there are a few for this type of issue but not that I can get to work. What I am trying to setup is probably best explained if you use the code below and try it yourself, but I'll try to explain myself.
I have several input fields which are cloned after they have data inputted into them. Now I am trying to integrate an autocomplete script with it. So that all the one has to do is type the name of a person, select it from the popup and it puts the data into the cells.
The issue is that it won't input data for anything but the initial row, because the cloner changes the id by increasing the id number everything its cloned. Can anyone point me in the right direction of how to increment the autocompleter? Or how to rerun for each clone?
Thanks everyone, and here are the files needed to replicate the issue.
SQL
-- Table structure for table `employees`
--
CREATE TABLE IF NOT EXISTS `employees` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`fname` varchar(50) NOT NULL,
`lname` varchar(50) NOT NULL,
`wage` int(12) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `employees`
--
INSERT INTO `employees` (`id`, `fname`, `lname`, `wage`) VALUES
(1, 'John', 'Doe', 25),
(2, 'Bob', 'Smith', 30);
test.php
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
//cloning script
$("#employee input").live("keyup", function(){
var id = this.id.match(/\d+/);
});
// The second requirement:
var uniqueIds = $("#employee tr").length;
$("#employee input[id^='employee_fname']").live("change", function(){
var $thisRow = $(this).closest("tr"),
$clone = $thisRow.clone(true), // Clone row
$inputs = $clone.find("input").val("");// Reset values, return all inputs
uniqueIds++; //Increment ID
$inputs[0].id = "employee_id" + uniqueIds;
$inputs[1].id = "employee_fname" + uniqueIds;
$inputs[1].id = "employee_lname" + uniqueIds;
$inputs[2].id = "employee_wage" + uniqueIds;
//$inputs.eq(0).focus(); // Focus on the first text field
$thisRow.after($clone); // Add row after current one
});
</script>
<script>
//autosuggest script
function lookup(employee_fname) {
if(employee_fname.length == 0) {
// Hide the suggestion box.
$('#suggestions').hide();
} else {
$.post("test_ac.php", {queryString: ""+employee_fname+""},function(data){
if(data.length >0) {
$('#suggestions').show();
$('#autoSuggestionsList').html(data);
}
});
}
} // lookup
function fill1(thisValue) {
$('#employee_fname').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
function fill2(thisValue) {
$('#employee_id').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
function fill3(thisValue) {
$('#employee_lname').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
function fill4(thisValue) {
$('#employee_wage').val(thisValue);
setTimeout("$('#suggestions').hide();", 200);
}
</script>
<style>
.suggestionsBox {
position: relative;
left: 30px;
margin-top:100px;
margin-left:-35px;
margin-right:0px;
margin-bottom:0px;
padding:0px;
width: 150px;
background-color: #212427;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
border: 2px solid #000;
color: #fff;
}
.suggestionList {
margin: 0px;
padding: 0px;
}
.suggestionList li {
margin: 0px 0px 3px 0px;
padding: 3px;
cursor: pointer;
}
.suggestionList li:hover {
background-color: #659CD8;
}
</style>
</head>
<body>
<table>
<tr>
<td width="200">
<div class="suggestionsBox" id="suggestions" style="display: none;">
<div class="suggestionList" id="autoSuggestionsList">
</div>
</div>
</td>
<td>
<table>
<tr>
<td width="120" align="left" style="width:120px;">ID</td>
<td width="120" align="left" style="width:120px;">First Name</td>
<td width="120" align="left" style="width:120px;">Last Name</td>
<td width="120" align="left" style="width:120px;">Wage</td>
</tr>
</table>
<table id="employee">
<tr>
<td align="left"><input type="text" id="employee_id" name="employee_id" style="width:100px; background-color:#e5e5e5;" readonly="readonly" onblur="fill2();"/></td>
<td align="left"><input type="text" id="employee_fname" name="employee_fname" style="width:100px;" onblur="fill1();" onkeyup="lookup(this.value);"/></td>
<td align="left"><input type="text" id="employee_lname" name="employee_lname" style="width:100px; background-color:#e5e5e5;" readonly="readonly" onBlur="fill3"/></td>
<td align="left"><input type="text" id="employee_wage" name="employee_wage" style="width:100px; background-color:#e5e5e5;" readonly="readonly" onblur="fill4();" /></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
test_ac.php
<?php
// PHP5 Implementation - uses MySQLi.
// mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase');
$db = new mysqli('localhost', 'root' ,'passsword', 'database');
if(!$db) {
// Show error if we cannot connect.
echo 'ERROR: Could not connect to the database.';
} else {
// Is there a posted query string?
if(isset($_POST['queryString'])) {
$queryString = $db->real_escape_string($_POST['queryString']);
// Is the string length greater than 0?
if(strlen($queryString) >0) {
// Run the query: We use LIKE '$queryString%'
// The percentage sign is a wild-card, in my example of countries it works like this...
// $queryString = 'Uni';
// Returned data = 'United States, United Kindom';
// YOU NEED TO ALTER THE QUERY TO MATCH YOUR DATABASE.
// eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10
$query = $db->query("SELECT fname, lname, id, wage FROM employees WHERE fname LIKE '$queryString%' LIMIT 10");
if($query) {
// While there are results loop through them - fetching an Object (i like PHP5 btw!).
while ($result = $query ->fetch_object()) {
// Format the results, im using <li> for the list, you can change it.
// The onClick function fills the textbox with the result.
// YOU MUST CHANGE: $result->value to $result->your_colum
echo '<li onClick="fill1(\''.$result->fname.'\');
fill2(\''.$result->id.'\');
fill3(\''.$result->lname.'\');
fill4(\''.$result->wage.'\');
">'.$result->lname. ',' .$result->fname.'</li>';
}
} else {
echo 'ERROR: There was a problem with the query.';
}
} else {
// Dont do anything.
} // There is a queryString.
} else {
echo 'There should be no direct access to this script!';
}
}
?>
Change the autosuggest script to the code below. This solved my issue.
var sourceElement;
//autosuggest script
function lookup2(source, employee_id) {
sourceElement = source;
if(employee_id.length == 0) {
// Hide the suggestion box.
$('#suggestions2').hide();
} else {
$.post("../../autocomplete/jobadd_employee.php", {queryString: ""+employee_id+""},function(data){
if(data.length >0) {
$('#suggestions2').show();
$('#autoSuggestionsList2').html(data);
}
});
}
} // lookup
function fill8(thisValue) {
$('#employee_id'+sourceElement.id.replace("employee_id","")).val(thisValue);
setTimeout("$('#suggestions2').hide();", 200);
}
function fill9(thisValue) {
$('#employee_fname'+sourceElement.id.replace("employee_id","")).val(thisValue);
setTimeout("$('#suggestions2').hide();", 200);
}
function fill10(thisValue) {
$('#employee_lname'+sourceElement.id.replace("employee_id","")).val(thisValue);
setTimeout("$('#suggestions2').hide();", 200);
}
function fill11(thisValue) {
$('#employee_wage'+sourceElement.id.replace("employee_id","")).val(thisValue);
setTimeout("$('#suggestions2').hide();", 200);
}