Can you pass searchData through rows().every()

Can you pass searchData through rows().every()

zgoforthzgoforth Posts: 493Questions: 98Answers: 2

Link to test case: https://jsfiddle.net/BeerusDev/vzehsqn8/213/

I am returning back to my original test case that works 90%, it makes no sense for me to even try and change the data structure (Even if It could possible save me 90 lines worth of code). In my rows.every(), I have a second large conditional if the result is undefined and todayStatus is n/a, so instead of that, because that happens when the searchData is outside of the current week, I would be able to set the search data to the current week then apply those counts and styles based upon that.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Are you asking about the searchData parameter that is part of the search plugin? If so its not something available for use outside of the search plugin, ie, you won't be able to use it in rowGroup.startRender.

    Its not clear what you are trying to do. Maybe you can describe your requirement so we can offer suggestions.

    Kevin

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    Sorry I am having a difficult time putting into words what I am trying to do. So hopefully you understand the working functionality of my DataTable right now.
    https://jsfiddle.net/BeerusDev/vzehsqn8/217/

    My filter works fine and shows everything during the current week and has a final count in the <tfoot> for each status across the board for the current day. But when I filter search for example, last week (6/21) nothing populates to the <tfoot> so a count isn't even applied for the search outside of the current week, that is all I have left to complete the table

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    You have this statement:

    var result = Object.keys(data).find(key => typeof data[key] === 'string' && data[key].startsWith(today));

    If you choose the previous week then this isn't going to work because the value of today won't be found, ie, undefined. Without understanding the goal of the solution its hard to say what you need to do. You will need to add code to handle the situation of todayStatus being undefined.

    Kevin

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    @kthorngren so I found another way around it instead of using that var result and todayStatus.

    It is nice because I was able to reduce the number of lines in my rows.every() from 90+ lines, to 20 lines. Here is the updated fiddle: https://jsfiddle.net/BeerusDev/gm10rqp7/84/

    My next question, I am going to have a function much like the one in my rows.every() creating a count, but need to apply it after the table is searched with (v) in my datepicker function. instead of isSame(today) I will do one for the is same as (v) the date searched. Would I include this is my rows.every(), or in my date picker function? I would assume datepicker function, because I cannot call v before it is initialized.

  • zgoforthzgoforth Posts: 493Questions: 98Answers: 2

    I am starting to wonder if this is even possible? The $("#dpicker") function is outside of the table declaration, so I do not know if I can include that inside at all.

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    You can use $('#dpicker').val() to get the date picker value from anywhere in the script.

    Kevin

Sign In or Register to comment.