Editable rows: exclude columns
Editable rows: exclude columns
I made my rows editable, but I want to exclude some columns so they can't be edited. My code is now like this:
[code]
$(document).ready(function() {
$('#relatiebeheer').dataTable( {
/* Mogelijkheid om horizontaal te scrollen */
"sScrollX": "100%",
"sScrollXInner": "200%",
"bScrollCollapse": true,
/* Vertalen van sommige objecten */
"oLanguage": {
"sLengthMenu": "Geef _MENU_ relaties per pagina weer",
"sInfo": "Weergave: _START_ van _END_ van in totaal _TOTAL_ relaties",
"sInfoFiltered": "(gefilterd uit _MAX_ relaties)"
}
});
/* Init DataTables */
var oTable = $('#relatiebeheer').dataTable();
/* Apply the jEditable handlers to the table */
$('td', oTable.fnGetNodes()).editable( 'DataTables-1.7.1/examples/examples_support/editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"col_id": this.getAttribute('category'),
"row_id": this.parentNode.getAttribute('id')
};
},
"height": "14px"
} );
} );[/code]
The table looks like this:
[code]
Organisatie
Naam
Adres
Postcode
<? echo $data->organisatie;?>
<? echo $data->voorletter . " " . $data->tussenvoegsel . " " . $data->achternaam;?>
<? echo $data->adres;?>
<? echo $data->postcode;?>
[/code]
[code]
$(document).ready(function() {
$('#relatiebeheer').dataTable( {
/* Mogelijkheid om horizontaal te scrollen */
"sScrollX": "100%",
"sScrollXInner": "200%",
"bScrollCollapse": true,
/* Vertalen van sommige objecten */
"oLanguage": {
"sLengthMenu": "Geef _MENU_ relaties per pagina weer",
"sInfo": "Weergave: _START_ van _END_ van in totaal _TOTAL_ relaties",
"sInfoFiltered": "(gefilterd uit _MAX_ relaties)"
}
});
/* Init DataTables */
var oTable = $('#relatiebeheer').dataTable();
/* Apply the jEditable handlers to the table */
$('td', oTable.fnGetNodes()).editable( 'DataTables-1.7.1/examples/examples_support/editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"col_id": this.getAttribute('category'),
"row_id": this.parentNode.getAttribute('id')
};
},
"height": "14px"
} );
} );[/code]
The table looks like this:
[code]
Organisatie
Naam
Adres
Postcode
<? echo $data->organisatie;?>
<? echo $data->voorletter . " " . $data->tussenvoegsel . " " . $data->achternaam;?>
<? echo $data->adres;?>
<? echo $data->postcode;?>
[/code]
This discussion has been closed.
Replies
$(rows).not('.class-of-rows-to-exclude').editable();
// caches the rows
var rows = oTable.fnGetNodes();
// makes the rows nodelist an jQuery object, finds all the td (columns), filters out the td with the class you set.
$(rows).find('td').not('.class-of-rows-to-exclude').editable();
With your code:
[code]
$(document).ready(function() {
$('#relatiebeheer').dataTable( {
/* Mogelijkheid om horizontaal te scrollen */
"sScrollX": "100%",
"sScrollXInner": "200%",
"bScrollCollapse": true,
/* Vertalen van sommige objecten */
"oLanguage": {
"sLengthMenu": "Geef _MENU_ relaties per pagina weer",
"sInfo": "Weergave: _START_ van _END_ van in totaal _TOTAL_ relaties",
"sInfoFiltered": "(gefilterd uit _MAX_ relaties)"
}
});
/* Init DataTables */
var oTable = $('#relatiebeheer').dataTable();
/* Apply the jEditable handlers to the table */
// caches the rows
var rows = oTable.fnGetNodes();
// makes the rows nodelist an jQuery object, finds all the td (columns), filters out the td with the class you set.
$(rows).find('td').not('.exclude').editable( 'DataTables-1.7.1/examples/examples_support/editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"col_id": this.getAttribute('category'),
"row_id": this.parentNode.getAttribute('id')
};
},
"height": "14px"
} );
} );
[/code]
[code]
Organisatie
Naam
Adres
Postcode
<? echo $data->organisatie;?>
<? echo $data->voorletter . " " . $data->tussenvoegsel . " " . $data->achternaam;?>
<? echo $data->adres;?>
<? echo $data->postcode;?>
[/code]