Child rows search ajax

Child rows search ajax

ctechukctechuk Posts: 12Questions: 5Answers: 0

Evening all,

how can I achieve search functionality for my child rows. I have come across posts suggesting adding hidden rows in main table. However I cannot get this to work using the below code as the sql source does not include field names:

return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
            '<tr style="background-color:#98bdf9">'+
                '<td><b>Piece Title:</b></td>'+
                '<td>'+d[10]+'</td>'+
                '<td><b>Date:</b></td>'+
                '<td>'+d[11]+'</td>'+
                '<td><b>Dimensions:</b></td>'+
                '<td>'+d[12]+'</td>'+
                '<td><b>Client Name:</b></td>'+
                '<td>'+d[13]+'</td>'+
                '<td><b>Date Sold:</b></td>'+
                '<td>'+d[14]+'</td>'+
            '</tr>'+
        '</table>';
        }
// manage product data table
    manageProductTable = $('#manageProductTable').DataTable({
        'ajax': myurl,
        'columns': [
            {"data": null, "class": "details-control", "orderable": false, "defaultContent": "", "width": "2%"},
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            null
            ],
        'order': []
    }); 

So else can I add the hidden child row data to the main table? Or have I got this totally wrong?

Any help would be greatly appreciated.

Thanks in advance.

Ctech

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,771

    My approach would be to show the child rows that match the search criteria on each draw. Its not really a search. Here is the example:
    http://live.datatables.net/cuqokuwo/1/edit

    The input has an event handler that simply draws the table. The draw event is used to open open the child rows that match the search criteria. First it gets the row indexes of the current page that match the search. This uses selector-modifier of the current page and the filter() API.

    Next it closes all rows on the current page. Then opens the matched rows using the indexes.

    This example uses array data but it could also use object data.

    Kevin

  • ctechukctechuk Posts: 12Questions: 5Answers: 0

    Kevin,

    I have taken a look and although it is a nice solution it doesnt really fit for how I want things to look. The search functionality is really what I am looking for where the result set reduces down to just the rows you are searching for.

    Do you have any other out the box suggestions?

    Again many thanks for your continued support. :)

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @ctechuk ,

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

This discussion has been closed.