eherve / mongoose-datatable

Server side dataTable request support for mongoose
MIT License
42 stars 28 forks source link

sSearch with date ranges #18

Closed ricardofbarros closed 10 years ago

ricardofbarros commented 10 years ago

Hello again,

I'm sniffing the code, I got to queryBuilder.js and I notice you ignore the sRangeSeparator param and I don't quite understand how you build the query, basically I'm using this add-on for data tables, strings work fine, but If I include dates, it just breaks, let me dump some of my requests sniffed with Firebug

_   1405941869040
bRegex  false
bRegex_0    false
bRegex_1    false
bRegex_2    false
bRegex_3    false
bRegex_4    false
bRegex_5    false
bSearchable_0   true
bSearchable_1   true
bSearchable_2   true
bSearchable_3   true
bSearchable_4   true
bSearchable_5   false
bSortable_0 true
bSortable_1 true
bSortable_2 true
bSortable_3 true
bSortable_4 true
bSortable_5 false
iColumns    6
iDisplayLength  10
iDisplayStart   0
iSortCol_0  0
iSortingCols    1
mDataProp_0 number.origin
mDataProp_1 campaign
mDataProp_2 usedBy.callcenter
mDataProp_3 timeInserted
mDataProp_4 usedBy.timeConsumed
mDataProp_5 5
sColumns    ,,,,,RoleId
sEcho   1
sSearch 
sSearch_0 test  
sSearch_1   
sSearch_2   
sSearch_3   
sSearch_4   
sSearch_5   
sSortDir_0  asc

This work just fine, and searches test on first column, but If I include date ranges on my HTML+JS, I will get something like this:

bRegex  false
bRegex_0    false
bRegex_1    false
bRegex_2    false
bRegex_3    false
bRegex_4    false
bRegex_5    false
bSearchable_0   true
bSearchable_1   true
bSearchable_2   true
bSearchable_3   true
bSearchable_4   true
bSearchable_5   false
bSortable_0 true
bSortable_1 true
bSortable_2 true
bSortable_3 true
bSortable_4 true
bSortable_5 false
iColumns    6
iDisplayLength  10
iDisplayStart   0
iSortCol_0  0
iSortingCols    1
mDataProp_0 number.origin
mDataProp_1 campaign
mDataProp_2 usedBy.callcenter
mDataProp_3 timeInserted
mDataProp_4 usedBy.timeConsumed
mDataProp_5 5
sColumns    ,,,,,RoleId
sEcho   4
sRangeSeparator ~
sSearch 
sSearch_0   ds
sSearch_1   
sSearch_2   
sSearch_3   ~
sSearch_4   ~
sSearch_5   
sSortDir_0  desc

I will give you my table structure so you can get an idea

                        <thead>
                            <tr>
                                <th>N&uacute;mero</th>
                                <th>Campanha</th>
                                <th>Callcenter</th>                                
                                <th>Data Inserido</th>                                
                                <th>Data Consumido</th>
                                <th class="no-sort">A&ccedil;&otilde;es</th>
                            </tr>
                        </thead>

I'm going to try to include dates and sRangeSepartator support to your package.

eherve commented 10 years ago

Hi,

The module has its own implementation for the date filtering (explain in the documentation). If you want to add the date range support I suggest that you do it with the condition handlers.

You may need to have the query, to check for the sRangeSeparator, so I can update the module to add the query parameter to the condition handlers.

And the range filtering, for your datatable plugin, could be a module of its own: mongoose-datatable-dt-condition-handler


Herve Eric

Le 21 juil. 2014 à 13:37, Ricardo Barros notifications@github.com a écrit :

Hello again,

I'm sniffing the code, I got to queryBuilder.js and I notice you ignore the sRangeSeparator param and I don't quite understand how you build the query, basically I'm using this add-on for data tables, strings work fine, but If I include dates, it just breaks, let me dump some of my requests sniffed with Firebug

_ 1405941869040 bRegex false bRegex_0 false bRegex_1 false bRegex_2 false bRegex_3 false bRegex_4 false bRegex_5 false bSearchable_0 true bSearchable_1 true bSearchable_2 true bSearchable_3 true bSearchable_4 true bSearchable_5 false bSortable_0 true bSortable_1 true bSortable_2 true bSortable_3 true bSortable_4 true bSortable_5 false iColumns 6 iDisplayLength 10 iDisplayStart 0 iSortCol_0 0 iSortingCols 1 mDataProp_0 number.origin mDataProp_1 campaign mDataProp_2 usedBy.callcenter mDataProp_3 timeInserted mDataProp_4 usedBy.timeConsumed mDataProp_5 5 sColumns ,,,,,RoleId sEcho 1 sSearch sSearch_0 test sSearch_1 sSearch_2 sSearch_3 sSearch_4 sSearch_5 sSortDir_0 asc

This work just fine, and searches test on first column, but If I include date ranges on my HTML+JS, I will get something like this:

bRegex false bRegex_0 false bRegex_1 false bRegex_2 false bRegex_3 false bRegex_4 false bRegex_5 false bSearchable_0 true bSearchable_1 true bSearchable_2 true bSearchable_3 true bSearchable_4 true bSearchable_5 false bSortable_0 true bSortable_1 true bSortable_2 true bSortable_3 true bSortable_4 true bSortable_5 false iColumns 6 iDisplayLength 10 iDisplayStart 0 iSortCol_0 0 iSortingCols 1 mDataProp_0 number.origin mDataProp_1 campaign mDataProp_2 usedBy.callcenter mDataProp_3 timeInserted mDataProp_4 usedBy.timeConsumed mDataProp_5 5 sColumns ,,,,,RoleId sEcho 4 sRangeSeparator ~ sSearch sSearch_0 ds sSearch_1 sSearch_2 sSearch_3 ~ sSearch_4 ~ sSearch_5 sSortDir_0 desc

I will give you my table structure so you can get an idea

                    <thead>
                        <tr>
                            <th>N&uacute;mero</th>
                            <th>Campanha</th>
                            <th>Callcenter</th>
                            <th>Data Inserido</th>
                            <th>Data Consumido</th>
                            <th class="no-sort">A&ccedil;&otilde;es</th>
                        </tr>
                    </thead>

I'm going to try to include dates and sRangeSepartator support to your package.

— Reply to this email directly or view it on GitHub https://github.com/eherve/mongoose-datatable/issues/18.

ricardofbarros commented 10 years ago

Okay, I'll try figure it out, thank you :+1: