Any Idea how to do adjust column filter value after refresh on respective column if columns hidden
Any Idea how to do adjust column filter value after refresh on respective column if columns hidden
shunottara17
Posts: 13Questions: 4Answers: 0
in ColVis
I am using $(this).parent().index()+':visible' in search filter but when I am using colvis with that then If column is hidden then after refresh filter value referring its original position. for Example there are 3 columns name, city, salary. If I hide name then If I am searching on city with individual column filter then after refresh the city filter value is placed in salary filter box. How to solved this ? please help.
This question has an accepted answers - jump to answer
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Sorry I am not able to provide test case. My question is when I am using colvis then after applying filter if I refresh the page the filter value take its original place. Can you please help how to solve?
Are you saying that you are using
stateSave
and, after reloading the page, all the filter inputs are displayed regardless of the hidden columns?Without a test case showing what you are doing its difficult to provide specific help. Use one of the templates provide here to provide a simple test case so we can help debug.
Kevin
See I have Enable stateSave
then colvis functionality and Individual column filter.
Case 1:
1. If columns are not hidden , then if I search a value on any column and on page reload filter value is in their respective position. For ex . there are 3 columns Name,City,Salary . No columns are hide. If I search on city column then after refresh filter value is in correct place. i.e on city column filter.
Case 2:
If any column is hidden , suppose Name column is hidden then if I apply filter on city and search "london" then its london data is filtered but after page refresh "london" this value is in salary search box because city was is 2nd position before column hiding.
How to solve this problem. I want all the filter value should be in correct position even column is hidden.please help
I don't want hidden column filter value or any data relevant to hidden column. I want to perform operation with only visible columns.
The way you add the column filters is custom to your environment. There is no set way to do this. For use to help please provide a test case so we can provide specific help to how your environment is setup. Here is a basic starter test case for you with stateSave and a colvis button.
http://live.datatables.net/fitupazo/1/edit
Kevin
http://live.datatables.net/vavasibu/2/edit?html,js,output
This is test case please look into these. First hide any column and then search into right hand side of that column and then see output
The only problem I see is that when clicking in the search input the column is sorted. This can be resolved by using
orderCellsTop
, for example:http://live.datatables.net/vavasibu/3/edit
Kevin
Hi Kevin,
I have enable orderCellsTop but not working. Could you please do like, first hide first Name column and then search a value on last name column and then reload a page. please try once.
please try once. then you will see that filter value gets shifted
You need to use
':visible'
in the loop to set the search input search values:+table.column(i+':visible').search()+
. Also you need to use thecolumn-visibility
to update the inputs each time the column visibility is changed. Here is the updated example:http://live.datatables.net/buhakete/1/edit
Kevin
Thank you so much its works