EloquentStudio / StreamTable.js

StreamTable.js streams data for tables in the background, updates and renders them using templating frameworks like Mustache.js, HandleBars.js
http://eloquentstudio.github.io/StreamTable.js/stream.html
MIT License
385 stars 77 forks source link

Search is not working if data is adding manually in StreamTable #37

Closed vaibhav8186 closed 5 years ago

vaibhav8186 commented 5 years ago

When data is filled in first request stream-table search is working but after adding data manually in the stream -table search is not working.

jiren commented 5 years ago

Let me know how are you adding data manually? If code snippet available add into comment.

vaibhav8186 commented 5 years ago

if($('#user_stream_table').length) $("#user_stream_table").stream_table(options, data) if typeof data isnt "undefined"

$('#show').click ->
  if $(this).text() == 'Show Approved'
    $(this).text('Show All')
    $('tr[hide]').removeAttr('hidden')
    $('#user_note_text').text('Showing approved users only.')
    st = $("#user_stream_table").data('st')
    st.data = []
    st.addData(approved)
  else
    $(this).text('Show Approved')
    $('tr[hide]').attr('hidden', 'true')
    $('#user_note_text').text('Showing all users.')
    st = $("#user_stream_table").data('st')
    st.data = []
    st.addData(data)
vaibhav8186 commented 5 years ago

After data adding manually if I search for something then
view = (record, index) -> if record.employee_detail record.id = record.employee_detail.employee_id this code is not getting record. That's why search is not working ....

jiren commented 5 years ago

when adding data, stream table creates search index so when you clear data search index needs to be clear. So callst.clearAndBuildTextIndex() after calling st.addData.