Comments (5)
My solution so far only works on sortable columns but you get the idea. Please advise!
I'm using notation of "f_" to denote a filter field
When the filter is applied on the scoped model I store the <%=session["last_changed"]%> to the filter applied. I have a list of filters for each model stored and save them as session vars
I iterate through each param filter for the model when the ajax request is exectued
session["last_changed"]=param if params[param] != session[param]
Also needed to remove the following, so that the filtered column headings appear even if no results are present
- unless smart_listing.empty?
_update_list.js.erb
var smart_listing = $('#<%= name %>').smart_listing();
smart_listing.update_list("<%= escape_javascript(render(:partial => part, :locals => {:smart_listing => smart_listing})) %>", <%= smart_listing_data.to_json.html_safe %>);
var item = $('#<%=session["last_changed"]%>');
var strLength= item.val().length * 2;
item.focus();
item[0].setSelectionRange(strLength, strLength);
_sortable.html.erb
<input autocomplete="off" class="smart_filters search" id="<%=attribute.gsub('.','_')%>" name=" <%=attribute%>" placeholder="<%=title%>..." value="<%=session['f_'+attribute.gsub(".","_")]%>" type="text">
<%= link_to url, :class => container_classes, :data => {:attr => attribute}, :remote => true do %>`
application.js.cofee
$ ->
$("body").on "keydown", ".smart_filters", ->
$('.smart_filters').keyup (e) ->
txtVal = $(this).val()
id= "#f_"+$(this).attr("id")
id = id.replace(".","_")
$(id).attr 'value', txtVal
$(id).trigger("keydown")
$(id).trigger("change")
return
In the controls for the smart listing filter I hide the input boxes inside the form
<input autocomplete="off" class=" search form-control" id="f_people_headline" name="f_people_headline" placeholder="Headline..." value="" type="hidden">
Some css to clear up the layout
.sortable{
margin-left:-5px;
display:inline;
border: 1px solid #CCC;
padding: 7px;
border-radius: 0 4px 4px 0;
background-color: #EFEFEF;
height: 30px;
}
.smart_filters{
width:70%;
min-width:40px;
display:inline;
font-weight: 400;
height: 30px;
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
background-color: #FFF;
padding: 6px 2px 6px 2px;
border: 1px solid #CCC;
}
See below an example of what it looks like.
I think it would be good to have this in the core feature list ;-)
from smart_listing.
Can you make a pull request with such feature?
from smart_listing.
Filtering per column is very interesting point. I just tried to integrate filter as a second header line under the sorting header elements. You see an example in the image below. But this only works, if I do not use your in-place editing. So I have to decide either using in-place editing or integrating column filters in the table.
Alternatively I can define the column filters outside but then their layout is different from the columns of the table, if I do not use fixed width.
Filtering itself I implemented on server side via params and scopes.
So I would appreciate a solution for this topic!
from smart_listing.
@jumhh, why in-place-editing breaks your column filters?
from smart_listing.
Closing due to lack of feedback.
from smart_listing.
Related Issues (20)
- Rails 5 Strong Parameters removes hash access for unpermitted params HOT 3
- Compatibility with rails 5.1 HOT 13
- be able to sort with an intance method of the class and not a column
- Prevent SQL Injection HOT 2
- Multiple params doesnt work after search HOT 1
- Update README regarding JS dependency HOT 1
- Pass locals params doesn't work HOT 1
- Rails 5.1 uses Webpack HOT 2
- Undefined local variable or method `smart_listing_resource' HOT 1
- Your site is down. HOT 1
- Elasticsearch with smart_listing
- Broken implicit sorting by join tables in v1.2.3 HOT 1
- Not all of the configured classes get applied?
- Replace kaminari with pagy
- The config editable class params should have side effect to broke gems
- Configured hidden class and popover_destroy command are not applied correctly
- needs to change pagination style
- "PG" Branch
- smart_listing.paginate broke with Ruby 3.1.1 HOT 3
- $(...).smart_listing is not a function HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smart_listing.