Server side processing with custom range filtering‎ - Page 2

Server side processing with custom range filtering‎

2»

Replies

  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Yusuf,

    Como posso aplicar as mesmas regras de data formato Brasil (dd/mm/yyyy) para os fitros individuais por coluna?
    Ao inves de eu ter que digitar 2003-06-01 no filtro da coluna order date, preciso digitar 01/06/2003

    Obrigado!

    --
    valmello
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    On the server side, convert the user input from text to date, then you can convert that date to whichever format is desired by the database.

    http://www.php.net/manual/pt_BR/function.strtotime.php
    http://www.php.net/manual/pt_BR/function.strftime.php
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Fbas,

    Isso aí eu tentei fazer. O problema é que com o código do numberone eu não consegui localizar o sql que faz esta consulta.
    Vou ver se ele responde depois.
    Com relação a largura e a posição dos textos das colunas, você sabe informar se tem como fazer isso. Determinar tamanhos diferentes para cadas uma assim como alinhas os textos à direita?
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I would convert the date in PHP, not in the database.

    for formatting, any classes you specify on the client side header will still be used (I think). If you want to format your row heading, simply use inline style or css class for the element. For column cells, you can specify css classes for each column .

    see http://www.datatables.net/ref and find the sClass intialization parameter.

    [code]
    /* Using aoColumnDefs */
    $(document).ready(function() {
    $('#example').dataTable( {
    "aoColumnDefs": [
    { "sClass": "my_class", "aTargets": [ 0 ] }
    ]
    } );
    } );

    /* Using aoColumns */
    $(document).ready(function() {
    $('#example').dataTable( {
    "aoColumns": [
    { "sClass": "my_class" },
    null,
    null,
    null,
    null
    ]
    } );
    } );
    [/code]
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Pow cara... eu acabei de ler isso e consegui. Já estava acessando o forum para dizer que já tinha conseguido.
    Obrigado mesmo assim!
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    What does "pow cara" mean? I don't understand that phrase - is it a slang?
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    edited July 2011
    Hi valmello,

    you can replace that input as datepicker and search for that.
    http://numberone.kodingen.com/datatables/examples/multi_filtering2/

    Second option is you put the date range "from~to" inputs there like the examples above.
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Yes! is slang. It's like I talk ... "Sorry man ..." We here in Brazil, mainly in Bahia, many speak slang.
    I used the google translator to write in English.
    By the way, what country are you from?

    Abraços!

    --
    valmello
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    numberone,

    Isso resolve perfeitamente.

    abraços!

    --
    valmello
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    USA. Texas here.
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    numberone,

    Como eu poderia utilizar o código abaixo para filtrar moeda no formato "10.325,33" ?

    Para imprimir na tela eu usei da seguinte forma abaixo, e está funcionando normalmente :

    [quote]

    $datatables->connect($config);

    $datatables
    ->select('orderNumber, orderDate, status, customerNumber')
    ->from('orders')

    // Adicionei este para moeda no formato 10.325,33

    ->edit_column('customerNumber', '$1', 'callback_my_formatNumber(customerNumber)');

    echo $datatables->generate();

    // Adicionei este para moeda no formato 10.325,33

    function my_formatNumber($number) { /// and this function
    return number_format($number,2,",",".");
    }

    [/quote]

    Agora eu queria aplicar isso ao filtro individual, ou seja, preciso digitar 10.325,33 e obter o resultado esperado.
    Eu tentei utilizar a mesma lógica que você aplicou com a data, mas não deu certo.
    Poderia me dar mais esta ajuda?

    Thanks!

    valmello
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    edited July 2011
    customerNumber is like 10325,33 in your database right ?
    and your textbox is fomatted like 10.325,33
    if so, if you remove dots from your textbox value while sending, filtering should work.

    something like,
    [code]
    $("#customerNumber_textbox").keyup( function () {
    oTable.fnFilter( $(this).val().replace('.', ''), 3); // 3 refers to index, starts with zero.
    } );
    [/code]
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    edited July 2011
    hi valmello,

    i think this is a better way for filtering dates (type only '03/2004' and see):
    http://numberone.kodingen.com/datatables/examples/multi_filtering2

    Regards,
    Yusuf
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Olá Yusuf,

    Com certeza esta forma que você descreveu agora ficou muito melhor.
    Já adotei ela e descartei a anterior.
    Valeu mesmo....

    Man, eu mandei uma mensagem para o Allan perguntendo-lhe sobre a exibição dos totais das páginas e o total de registros do banco e el me respondeu o seguite:

    [quote]

    > 2. iTotalMarket à the result showed the page and not the total records

    It wouldn't since DataTables with server-side processing only knows about the data that is visible on each page. It doesn't know what data is on the other pages, since there might be millions of them. As such, if you want to show a sum total for all rows, that would need to be calculated on the server-side and passed back through the JSON object to be displayed by your Javascript (either fnDrawCallback or fnServerData could be utilised for this).

    > 3. Passing to the second page, using the pagination, which advises aaData[aiDisplay[i]] is undefined.

    This again is related to the fact that you are using server-side processing, which behaves slightly different from client-side processing. As you see with your point 1, fnFooterCallback does work, but you don't have the full data set to work with - sum total calculations need to be done with the full data set - i.e. on the server-side.

    [/quote]

    Baseado na resposta dele é possível fazer algo?

    ::::::

    Outra coisa.
    É possível levar os input do footer na posição entre header e o body como na imagem a seguir, levando todas as caracteristicas que já fizemos até aqui?

    http://www.q-werty.com/allan/datatable.gif
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    edited July 2011
    Here is the example about how to do that.

    http://www.2shared.com/file/oWMIlvKs/percentage.html
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    É possível levar os input do footer na posição entre header e o body como na imagem a seguir, levando todas as caracteristicas que já fizemos até aqui?

    http://www.q-werty.com/allan/datatable.gif
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    http://datatables.net/forums/discussion/3124/sort-and-individual-column-filtering-from-the-head/
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Yusuf,

    With your help I got a result sessancional in my project.
    Only the question of the total still was not 100% because the formatting of values ​​is different here in Brazil.
    But as I have bothered you, I will make several attempts before resorting to you.
    Thank you so much for the strength you've given me.

    Thank you for real!

    Big hug!

    -
    valmello
  • numberonenumberone Posts: 86Questions: 0Answers: 0
    glad to hear that ^^.

    You can play with this code to make percentage that u want ^^..
    [code]
    /* Modify the footer row to match what we want */
    var nCells = nRow.getElementsByTagName('th');
    /* nCells[1].innerHTML = parseInt(iPageMarket * 100)/100 +
    '% ('+ parseInt(iTotalMarket * 100)/100 +'% total)'; */
    nCells[1].innerHTML = (iPageMarket*100/iTotalMarket).toFixed(5) +
    '% ('+ 100 +'% total)';
    [/code]

    Regards,
    Yusuf
  • valmellovalmello Posts: 27Questions: 4Answers: 0
    Yusuf,

    Bom dia irmão!
    Quanto tempo heim? Terminei o sistema e apliquei o DataTables e ficou muito bom, porém surgiu uma dúvida e não consegui resolver.
    Seguite: Aqui no Brasil, a nossa lingua utiliza muito caracteres especiais, tipo. "você", "Ântonio", e pude verificar que quando no banco de dados constam palavras com caracteres especiais o campo não aparece no DataTable.
    Como eu poderia resolver esta situação?

    Grande abraço!

    valmello (estou de volta... risos)
This discussion has been closed.