Hide columns from server side (Java)
Hide columns from server side (Java)
SimonDevineau
Posts: 1Questions: 0Answers: 0
Hi everyone,
Firstly, I want to apologize if this question has already been answered and also for the mistakes I will write, I do not speak English very well.
I read some posts about it but they did not really answer to my questions and they are now closed.
I would like to hide columns of table my using the server side features.
To be precised, my table could have a big amount of columns so by using a search filter, I would like to choose the columns I want to display.
I initialize my table in this way on my jsp :
[code]
$(document).ready(function() {
$('#listingTypeTable').dataTable({
//Enables columns reorder
"sDom": 'Rlfrtip',
"bProcessing" : true,
"bServerSide" : true,
"sAjaxSource" : "listingType/tables",
"aoColumnDefs" : ${reportParams.mData}
});
});
[/code]
the columns and data are well displayed, there is no problem.
Here an example of my initial aoColumnsDefs:
[code]
[{"aTargets":[0],"mData":"year","sTitle":"Year","bVisible":true},
{"aTargets":[1],"mData":"monthAbbreviation","sTitle":"Month","bVisible":true},
{"aTargets":[2],"mData":"numActiveListings","sTitle":"Active","bVisible":true},
{"aTargets":[3],"mData":"previewed","sTitle":"Listing Previewed","bVisible":true}, ....... ]
[/code]
But now I want to hide some columns according to the user criteria.
I tried to send to the client a new definition of aoColumnDefs with bVisible:false but I do not succeed to override the initial one.
Do I have to use fnServerData ? or is it possible to initialized my columns on the server side? because when I remove "aoColumnDefs" : ${reportParams.mData}, myServlet is not reached anymore. There is no XHR request sent from the client.
I tried to be the clearest as possible, but quiet hard for me ;-), if you need some details, I will be glad to answer it
Thank you in advance for your answer
Firstly, I want to apologize if this question has already been answered and also for the mistakes I will write, I do not speak English very well.
I read some posts about it but they did not really answer to my questions and they are now closed.
I would like to hide columns of table my using the server side features.
To be precised, my table could have a big amount of columns so by using a search filter, I would like to choose the columns I want to display.
I initialize my table in this way on my jsp :
[code]
$(document).ready(function() {
$('#listingTypeTable').dataTable({
//Enables columns reorder
"sDom": 'Rlfrtip',
"bProcessing" : true,
"bServerSide" : true,
"sAjaxSource" : "listingType/tables",
"aoColumnDefs" : ${reportParams.mData}
});
});
[/code]
the columns and data are well displayed, there is no problem.
Here an example of my initial aoColumnsDefs:
[code]
[{"aTargets":[0],"mData":"year","sTitle":"Year","bVisible":true},
{"aTargets":[1],"mData":"monthAbbreviation","sTitle":"Month","bVisible":true},
{"aTargets":[2],"mData":"numActiveListings","sTitle":"Active","bVisible":true},
{"aTargets":[3],"mData":"previewed","sTitle":"Listing Previewed","bVisible":true}, ....... ]
[/code]
But now I want to hide some columns according to the user criteria.
I tried to send to the client a new definition of aoColumnDefs with bVisible:false but I do not succeed to override the initial one.
Do I have to use fnServerData ? or is it possible to initialized my columns on the server side? because when I remove "aoColumnDefs" : ${reportParams.mData}, myServlet is not reached anymore. There is no XHR request sent from the client.
I tried to be the clearest as possible, but quiet hard for me ;-), if you need some details, I will be glad to answer it
Thank you in advance for your answer
This discussion has been closed.