Datatables Editable - Highlight returned results
Datatables Editable - Highlight returned results
I'm using the jquery datatables 1.9.2 plugin with editable and it's working well.
I'm trying to make the results of an edited field go bold when changed and stay bold until the entire page is reloaded.
This is the code I'm using :
[code]
$(document).ready(function() {
oTable = $('#exnew').dataTable({
"aLengthMenu": [[10, 25, 50]]
});
$('#exnew').dataTable().makeEditable({
sUpdateURL: "do.php",
"aoColumns": [
null,
null,
{},
{},
{
event: 'click', type: 'select', onblur: 'submit',
data: "{'0':'No','1':'YES','2':'Maybe','3':'Possibly'}",
}]
});
});
ABCDE
ABCDE
AAA
BBB
CCC
DDD
YES
[/code]
do.php contains :
[code]<?php
//do.php
$id = $_REQUEST['id'] ;
$value = $_REQUEST['value'] ;
$column = $_REQUEST['columnName'] ;
$columnPosition = $_REQUEST['columnPosition'] ;
$columnId = $_REQUEST['columnId'] ;
$rowId = $_REQUEST['rowId'] ;
/* Update a record using information about id, columnName (property
of the object or column in the table) and value that should be
set */
echo $value;
?>[/code]
This is working and any changes I make are updated on the form correctly.
But what I would like is if a user selects either YES, Maybe or Possibly from the last columns drop down list, then the result is shown back in the correct column in BOLD.
I'm assuming I need to add some return function to this to update the cell of the value returned:
[code]{
event: 'click', type: 'select', onblur: 'submit',
data: "{'0':'No','1':'YES','2':'Maybe','3':'Possibly'}",
}[/code]
Can anyone advise how I would do this ?
Couple of links, in case it helps :
I'm trying to make the results of an edited field go bold when changed and stay bold until the entire page is reloaded.
This is the code I'm using :
[code]
$(document).ready(function() {
oTable = $('#exnew').dataTable({
"aLengthMenu": [[10, 25, 50]]
});
$('#exnew').dataTable().makeEditable({
sUpdateURL: "do.php",
"aoColumns": [
null,
null,
{},
{},
{
event: 'click', type: 'select', onblur: 'submit',
data: "{'0':'No','1':'YES','2':'Maybe','3':'Possibly'}",
}]
});
});
ABCDE
ABCDE
AAA
BBB
CCC
DDD
YES
[/code]
do.php contains :
[code]<?php
//do.php
$id = $_REQUEST['id'] ;
$value = $_REQUEST['value'] ;
$column = $_REQUEST['columnName'] ;
$columnPosition = $_REQUEST['columnPosition'] ;
$columnId = $_REQUEST['columnId'] ;
$rowId = $_REQUEST['rowId'] ;
/* Update a record using information about id, columnName (property
of the object or column in the table) and value that should be
set */
echo $value;
?>[/code]
This is working and any changes I make are updated on the form correctly.
But what I would like is if a user selects either YES, Maybe or Possibly from the last columns drop down list, then the result is shown back in the correct column in BOLD.
I'm assuming I need to add some return function to this to update the cell of the value returned:
[code]{
event: 'click', type: 'select', onblur: 'submit',
data: "{'0':'No','1':'YES','2':'Maybe','3':'Possibly'}",
}[/code]
Can anyone advise how I would do this ?
Couple of links, in case it helps :
This discussion has been closed.
Replies
Has anyone any ideas on this ?
I have it working as I want, but it would be good to update the value returned to the cell.
Thanks
I've edited this and now i get an alert if the value is 1 or greater.. But how do I update cell value and make it bold ?
[code]{
event: 'click', type: 'select', onblur: 'submit',
data: "{'0':'No','1':'YES','2':'Maybe','3':'Possibly'}",
fnOnCellUpdated: function(sStatus, sValue, settings){
if (sValue >=1) {
alert("(Cell Callback): Cell is updated with value " + sValue);
}
},
}[/code]
Thanks :)
I've sort of got this working. Every update is now highlighted in bold.
Would be nice if I could to to work for just specific columns and based on the sValue >=1
Any ideas how to do that ?
[code] $('#exnew tbody td').click( function () {
aPos = oTable.fnGetPosition( this );
aData = oTable.fnGetData( aPos[0] );
$(this).css('font-weight', 'bold');
} );[/code]
You could use the nth-child selector of jQuery: http://api.jquery.com/nth-child-selector/
Allan
I have a couple of columns and these contain dropdown lists as shown above. If when the page is originally loaded the value behind the dropdown list is 1 or greater the result is shown in bold.
What I'm trying to do is allow the user to edit the entry using the dropdown list and change the text bold if the dropdown value is 1 or more.
Would that work with nth-child-selector ?
Thanks