How to add a row dynamically when using server-side processing?
How to add a row dynamically when using server-side processing?
integral_dev
Posts: 5Questions: 0Answers: 0
Hi, I am using datatables with server-side processing turned on.
There are instances where persistence in database is done asynchronously, but I do get the event on server when something will be added and need to show that on the client. In that case, I want to add a row on client and increment the count.
The way I implemented is by following these steps:
1. set bserverside to false
2. call fnAddData()
3. set bserverside to true
This way row gets added on the client but since client only had current page - the total number of records become (page size + 1) instead of (previous total count + 1). I tried changing settings._iRecordsTotal but it doesnt help.
Can you please help or provide me with any other approach? Thanks so much!!
There are instances where persistence in database is done asynchronously, but I do get the event on server when something will be added and need to show that on the client. In that case, I want to add a row on client and increment the count.
The way I implemented is by following these steps:
1. set bserverside to false
2. call fnAddData()
3. set bserverside to true
This way row gets added on the client but since client only had current page - the total number of records become (page size + 1) instead of (previous total count + 1). I tried changing settings._iRecordsTotal but it doesnt help.
Can you please help or provide me with any other approach? Thanks so much!!
This discussion has been closed.
Replies
Allan
For my problem, I was looking for a solution where I want to do pagination and sorting by server. Only in case of live updates I need to add rows dynamically to datatable - since data gets stored in table asynchronously on the server - the pagination view will be consistent. The only issue is that server generates an event when something needs to be added - not when its finally persisted.
Can you provide any alternate mechanism to do that? Thanks again.
I am now able to set total count when using client side pagination.
settings.aiDisplayMaster.length = totalCount + 1;
I am using table.fnDraw() but for some reason it is breaking. Can you please point me to the correct API which can redraw the table when its client side implementation.