My mikrotik api shows my datatable total pages but not displaying data

My mikrotik api shows my datatable total pages but not displaying data

shyriadshyriad Posts: 11Questions: 2Answers: 0
edited July 31 in Free community support
<?php
namespace App\Controllers;
use App\Libraries\Mikweb;

class Logs extends Security_Controller {

    function __construct() {
        parent::__construct();
        $this->access_only_admin_or_settings_admin();
    }
    function index() {
    
        return $this->template->rander("logs/index");
    }
    //get data for logs list
    function list_data() {      
        $API = new Mikweb();        
        $API->connect('192.168.88.6', 'shyriad', 'shyriad#1332');   
        $list_data = $API->comm('/ppp/profile/print');
        $result = array();      
        foreach ($list_data as $data) {
        $result[] = $this->_make_row($data);

        }
        echo json_encode(array("data" => $result));     
        
    }
    
    //prepare an client groups category list row
    private function _make_row($data) {
        return array($data->name);
        
    }   

}

/* End of file logs.php */
/* Location: ./app/controllers/logs.php */

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 14,458Questions: 1Answers: 2,464

    What happens when you run the PHP file on the server? Are you getting the data there? Are you seeing errors?

    Colin

  • shyriadshyriad Posts: 11Questions: 2Answers: 0

    my data is present in debugger. but cannot display .

  • kthorngrenkthorngren Posts: 16,808Questions: 25Answers: 3,983

    Guessing you need to use ajax.dataSrc like the second example in the docs.

    Kevin

  • shyriadshyriad Posts: 11Questions: 2Answers: 0
    edited July 31
    <script type="text/javascript">
        $(document).ready(function () {
            $("#logs-table").appTable({
                source: '<?php echo_uri("logs/list_data") ?>',
                columns: [
                    //{title: '<?php echo app_lang("id") ?>'},                  
                    {title: '<?php echo app_lang("name") ?>'},                
                    {title: '<?php echo app_lang("topics") ?>'},                
                    {title: '<?php echo app_lang("message") ?>'},
                    //{title: '<i data-feather="menu" class="icon-16"></i>', "class": "text-center option w100"}
                ]           
            });
        });
    </script>
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • shyriadshyriad Posts: 11Questions: 2Answers: 0

    i have already used it.

  • kthorngrenkthorngren Posts: 16,808Questions: 25Answers: 3,983

    I'm not sure what appTable is but this is forum is for the Datatables library. You will need to post your questions on a support forum for appTable.

    Kevin

  • shyriadshyriad Posts: 11Questions: 2Answers: 0

    my json format is ok but i canot get output in table have a look


  • shyriadshyriad Posts: 11Questions: 2Answers: 0

    please help me out. i am stuck on this

  • kthorngrenkthorngren Posts: 16,808Questions: 25Answers: 3,983
    Answer ✓

    Did you follow the troubleshooting steps at the link provided?
    https://datatables.net/manual/tech-notes/4

    Since parameter is in integer, 0, Datatables is configured to look for array structured data. But you are using objects so you need to use columns.data. See the Ajax docs for details.

    Kevin

  • shyriadshyriad Posts: 11Questions: 2Answers: 0

    Thanks Kthorngren. It works. Thanks a lot.

Sign In or Register to comment.