Best data source option for datatable

Best data source option for datatable

sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0

Hey All,
I have a C# application which sends data via UDP socket every 3-5 second. I want to display that data in a datatable and it should refresh as new data comes. I am receiving the data via a python script and writing it to a json file. I am using django server.

Any alternate approach is welcomed.

Replies

  • kthorngrenkthorngren Posts: 20,299Questions: 26Answers: 4,769

    Is this question for the same page as your other thread?

    I am receiving the data via a python script and writing it to a json file.

    Does the JSON file continually grow or are you rewriting the file each update? And are you returning the whole file to Datatables?

    I would look at using a sqlite DB to store the C# data. Then use a jQuery Ajax request to fetch the latest data. In the success function use rows.add() to add to the Datatable.

    In the table I would use an auto incrementing field as an index and send that along with the data. Each Ajax fetch can use the data option to supply the last index received. The Python script can then fetch the new indexes and return those.

    Kevin

  • sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0

    The json file is re-written each time. Yes, the whole file is read by datatable and then using dataSrc I point to the key which is to be read.

    Is there any way in which writing to a database can be avoided? The application is time sensitive and writing to db and then reading from it may be costly.

  • kthorngrenkthorngren Posts: 20,299Questions: 26Answers: 4,769

    In your server code you can do whatever meets your needs. Datatables doesn't know about nor does it care. All Datatables cares about is getting a JSON data source as described here:
    https://datatables.net/manual/ajax#JSON-data-source

    Kevin

This discussion has been closed.