Showing 0 to 0 of 0 entries (filtered from NaN total entries)

Showing 0 to 0 of 0 entries (filtered from NaN total entries)

peter1005peter1005 Posts: 2Questions: 1Answers: 0
edited September 2018 in Free community support

hi, My datatable shows some rows but doesn't show records total in the footer of the table.why?

this is my JSON:

{"data":[{"DT_RowId":"row_2","shipping_id":"2","shipping_name":"\u5230\u5e97\u53d6\u8ca8","shipping_code":"1","shipping_mode":"3","shipping_order":"3","is_online":"2","is_sub_rule":"0","shipping_fee":"80","base_fee":"0"},{"DT_RowId":"row_3","shipping_id":"3","shipping_name":"\u570b\u5916\u8a02\u55ae","shipping_code":"1","shipping_mode":"1","shipping_order":"2","is_online":"1","is_sub_rule":"0","shipping_fee":"80","base_fee":"0"},{"DT_RowId":"row_9","shipping_id":"9","shipping_name":"\u5b85\u914d","shipping_code":"postoffice","shipping_mode":"1","shipping_order":"5","is_online":"1","is_sub_rule":"0","shipping_fee":"50","base_fee":"30"},{"DT_RowId":"row_10","shipping_id":"10","shipping_name":"\u8ca8\u904b","shipping_code":"freight","shipping_mode":"2","shipping_order":"4","is_online":"1","is_sub_rule":"0","shipping_fee":"50","base_fee":"0"},{"DT_RowId":"row_12","shipping_id":"12","shipping_name":"aaa","shipping_code":"ccc","shipping_mode":"1","shipping_order":"0","is_online":"0","is_sub_rule":"0","shipping_fee":"100","base_fee":"0"},{"DT_RowId":"row_13","shipping_id":"13","shipping_name":"bbb","shipping_code":"bbb","shipping_mode":"1","shipping_order":"0","is_online":"0","is_sub_rule":"0","shipping_fee":"100","base_fee":"0"},{"DT_RowId":"row_14","shipping_id":"14","shipping_name":"777","shipping_code":"cvs","shipping_mode":"1","shipping_order":"0","is_online":"1","is_sub_rule":"0","shipping_fee":"100","base_fee":"0"}],"options":{"shipping_code":[{"value":1,"label":"\u7e3d\u91d1\u984d x \u5143\u5167\u6536\u53d6 y \u5143\u57fa\u672c\u904b\u8cbb\uff0c\u8d85\u904e\u5f8c\u6539\u6536 z \u5143\u57fa\u672c\u904b\u8cbb"},{"value":2,"label":"\u7e3d\u91d1\u984d x \u5143\u5167\u6536\u53d6 y \u5143\u57fa\u672c\u904b\u8cbb\uff0c\u8d85\u904e\u5f8c\u6539\u6536 z \u5143\u57fa\u672c\u904b\u8cbb (\u4f7f\u7528\u904b\u8cbb\u6a19\u7c64)"},{"value":3,"label":"\u8cfc\u8cb7 x \u4ef6\u5546\u54c1\u5167\u6536\u53d6 y \u5143\u57fa\u672c\u904b\u8cbb\uff0c\u8d85\u904e\u5f8c\u6539\u6536 z \u5143\u57fa\u672c\u904b\u8cbb"},{"value":4,"label":"\u8cfc\u8cb7 x \u4ef6\u5546\u54c1\u5167\u6536\u53d6 y \u5143\u57fa\u672c\u904b\u8cbb\uff0c\u8d85\u904e\u5f8c\u6539\u6536 z \u5143\u57fa\u672c\u904b\u8cbb (\u4f7f\u7528\u904b\u8cbb\u6a19\u7c64)"},{"value":5,"label":"\u8cfc\u8cb7 x \u4ef6\u5546\u54c1\u5167\uff0a\u6bcf\u4ef6\uff0a\u6536\u53d6 y \u5143\u57fa\u672c\u904b\u8cbb\uff0c\u8d85\u904e\u5f8c\uff0a\u6bcf\u4ef6\uff0a\u6539\u6536 z \u5143\u57fa\u672c\u904b\u8cbb"},{"value":6,"label":"\u514d\u6536\u57fa\u672c\u904b\u8cbb"}],"shipping_mode":[{"value":1,"label":"\u5b85\u914d"},{"value":2,"label":"\u81ea\u53d6"},{"value":3,"label":"\u8d85\u5546"}]},"files":[]}

My php code:

Editor::inst( $db, $sql_details['prefix'].'shipping', 'shipping_id' )
->fields(
Field::inst('shipping_id')->set(false),
Field::inst( 'shipping_name' ),
Field::inst('shipping_code')
->options(function (){
return $GLOBALS['_SETUP']['shipping_code'];
})
Field::inst( 'shipping_mode' )
->options(function (){
return $GLOBALS['_SETUP']['shipping_mode'];
})
->setFormatter( 'Format::ifEmpty', 0 ),
Field::inst( 'shipping_order' )->setFormatter( 'Format::ifEmpty', 0 )->validator( Validate::numeric() ),
Field::inst( 'is_online' )->setFormatter( 'Format::ifEmpty', 0 )->validator( Validate::numeric() ),
Field::inst( 'is_sub_rule' )->setFormatter( 'Format::ifEmpty', 0 )->validator( Validate::numeric() ),
Field::inst( 'shipping_fee' )->setFormatter( 'Format::ifEmpty', 0 )->validator( Validate::numeric() ),
Field::inst( 'base_fee' )->setFormatter( 'Format::ifEmpty', 0 )->validator( Validate::numeric() )
)
->process( $_POST )
->json();

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    My datatable shows some rows but doesn't show records total in the footer of the table.why?

    Looks lie the json response has 7 rows. Is that what you see in your table"

    Do you have server side processing (serverSide) enabled?

    Do you see any errors in your browser's console?

    Please post your Datatables init code. Can you provide a link to your page or a test case replicating the problem?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • peter1005peter1005 Posts: 2Questions: 1Answers: 0
    edited September 2018

    hi, Kevin:
    There is no error in my browser console.
    my javascript code:

    let table = $(table_name).DataTable({
                 dom: "Bfrtip",
                searching: false, 
                serverSide: true,
                ajax: {
                    url:'ajax/shipping/handler.php',
                    type: "GET",
                    data: function ( d ) {
                        var formObj =  $("form[name=search_form]").serializeObject();
                        $("form[name=search_form] input:checkbox").each(function (i, chk) {
                            formObj[chk.name] = chk.checked;
                        });
                        $.extend(true, d , formObj);
                    }
                },
                columns:[                
                    {
                              data: null,
                              defaultContent: '',
                              className: 'select-checkbox',
                              orderable: false
                    },
                    { data: 'shipping_name', defaultContent: '' },
                    { data: 'shipping_order', defaultContent: '' },                
                    { 
                        data: 'shipping_mode',
                        render: function ( data, type, row ) {
                            return renderOption(table, data, 'shipping_mode');
                        }
                    },
                    { data: 'max_amt' },
                    { data: 'base_fee' },
                    { data: 'shipping_fee' },
                    
                ],
                "order": [[ 2, "desc" ]],
                select: true,
                buttons: [
                    { extend: 'create', editor: editor},
                    { extend: 'edit',   editor: editor},
    
                ],
            });
    
    
  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    You have serverSide processing enabled. In this case your server script is expected to handle the parameters and provide the responses as described here:
    https://datatables.net/manual/server-side

    Your json response doesn't appear to have all the fields expected like recordsTotal and recordsFiltered that are used as part of the server side processing function. Does your server script support this?

    Do you need server side processing enabled? See this FAQ:
    https://datatables.net/faqs/index#speed

    Kevin

This discussion has been closed.