ServerSide: true, and I'm not having a successful outcome result for a table

ServerSide: true, and I'm not having a successful outcome result for a table

klermannklermann Posts: 277Questions: 67Answers: 1

Hello, I'm having my json return mode serverSide: true, and I'm not having a successful outcome result for a table, where is the error and how should I set the data that returns with json to a table to work in serverSide mode?

{"draw":1,"start":10,"length":5,"iTotalRecords":25,"iTotalDisplayRecords":0,"dataReceitas":null,"data":[{"id":5,"descricaoReceita":"Receita 5555","dataReceita":{"year":2017,"month":"AUGUST","dayOfMonth":8,"dayOfWeek":"TUESDAY","era":"CE","dayOfYear":220,"leapYear":false,"monthValue":8,"chronology":{"id":"ISO","calendarType":"iso8601"}},"valorReceita":5000.00,"receitaFixa":true,"receitaFixaQuantidade":0,"receitaFixaTempo":"SEMANAS","repetirLancReceita":false,"repetirPorPeriodo":"SEMANAL","pagamento":false,"addObservacao":"dgdg","tipoReceitas":[{"id":3,"nome":"Tipo 3","corTipoReceita":"#AXVXDE","nomeTipoReceita":"Tipo 3"}],"minhasContas":[{"id":7,"nome":"Contas 7","dataAcesso":{"year":2017,"month":"MAY","dayOfMonth":1,"dayOfWeek":"MONDAY","era":"CE","dayOfYear":121,"leapYear":false,"monthValue":5,"chronology":{"id":"ISO","calendarType":"iso8601"}},"saldoAnterior":0.00,"saldoAtual":4564.00,"saldoFinal":6320.00,"tipo":"POUPANCA","cor":"#424345","dashBoard":false}],"etiquetas":[{"id":4,"nome":"Etiqueta 4","minhasReceitas":null}],"cor":"rgb(143, 1, 225, 1)"},{"id":6,"descricaoReceita":"Receita 4545","dataReceita":{"year":2017,"month":"AUGUST","dayOfMonth":7,"dayOfWeek":"MONDAY","era":"CE","dayOfYear":219,"leapYear":false,"monthValue":8,"chronology":{"id":"ISO","calendarType":"iso8601"}},"valorReceita":5000.00,"receitaFixa":true,"receitaFixaQuantidade":1,"receitaFixaTempo":"MESES","repetirLancReceita":false,"repetirPorPeriodo":"QUINZENAL","pagamento":false,"addObservacao":"dgdg","tipoReceitas":[],"minhasContas":[{"id":6,"nome":"Contas 6","dataAcesso":{"year":2017,"month":"MAY","dayOfMonth":1,"dayOfWeek":"MONDAY","era":"CE","dayOfYear":121,"leapYear":false,"monthValue":5,"chronology":{"id":"ISO","calendarType":"iso8601"}},"saldoAnterior":0.00,"saldoAtual":4564.00,"saldoFinal":1234.00,"tipo":"OUTROS","cor":"#ccc545","dashBoard":false}],"etiquetas":[{"id":3,"nome":"Etiqueta 3","minhasReceitas":null}],"cor":"rgb(255, 128, 0, 0.9)"},{"id":7,"descricaoReceita":"Receita 7777","dataReceita":{"year":2017,"month":"AUGUST","dayOfMonth":8,"dayOfWeek":"TUESDAY","era":"CE","dayOfYear":220,"leapYear":false,"monthValue":8,"chronology":{"id":"ISO","calendarType":"iso8601"}},"valorReceita":5000.00,"receitaFixa":true,"receitaFixaQuantidade":0,"receitaFixaTempo":"SEMANAS","repetirLancReceita":false,"repetirPorPeriodo":"ANUAL","pagamento":false,"addObservacao":"dgdg","tipoReceitas":[],"minhasContas":[{"id":5,"nome":"Contas 5","dataAcesso":{"year":2017,"month":"JUNE","dayOfMonth":1,"dayOfWeek":"THURSDAY","era":"CE","dayOfYear":152,"leapYear":false,"monthValue":6,"chronology":{"id":"ISO","calendarType":"iso8601"}},"saldoAnterior":0.00,"saldoAtual":7897.00,"saldoFinal":4564.00,"tipo":"POUPANCA","cor":"#q4weq5","dashBoard":false}],"etiquetas":[{"id":2,"nome":"Etiqueta 2","minhasReceitas":null}],"cor":"rgb(143, 0, 0, 1)"},{"id":8,"descricaoReceita":"Receita 8","dataReceita":{"year":2016,"month":"AUGUST","dayOfMonth":2,"dayOfWeek":"TUESDAY","era":"CE","dayOfYear":215,"leapYear":true,"monthValue":8,"chronology":{"id":"ISO","calendarType":"iso8601"}},"valorReceita":7897.00,"receitaFixa":false,"receitaFixaQuantidade":0,"receitaFixaTempo":"SEMANAS","repetirLancReceita":false,"repetirPorPeriodo":"SEMANAL","pagamento":false,"addObservacao":"dgdg","tipoReceitas":[{"id":6,"nome":"Tipo 6","corTipoReceita":"#FDSFKK","nomeTipoReceita":"Tipo 6"}],"minhasContas":[{"id":4,"nome":"Contas 4","dataAcesso":{"year":2017,"month":"APRIL","dayOfMonth":1,"dayOfWeek":"SATURDAY","era":"CE","dayOfYear":91,"leapYear":false,"monthValue":4,"chronology":{"id":"ISO","calendarType":"iso8601"}},"saldoAnterior":0.00,"saldoAtual":3456.00,"saldoFinal":3652.00,"tipo":"POUPANCA","cor":"#q8qwe5","dashBoard":false}],"etiquetas":[{"id":1,"nome":"Etiqueta 1","minhasReceitas":null}],"cor":"rgb(50, 90, 100, 0.9)"}]}

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    we see the data but we would actually need to see the code sense you have arrays inside of your objects inside your array.

  • klermannklermann Posts: 277Questions: 67Answers: 1

    And where do I find where the file is located for me to post?

  • kthorngrenkthorngren Posts: 21,260Questions: 26Answers: 4,934

    I think the problem is that you are not returning the data correctly. According to the server side doc you need to return the following parameters: draw, recordsTotal, recordsFiltered and data.

    Your are retuning the following: draw, start, length, iTotalRecords, TotalDisplayRecords,data, plus others.

    start and length are parameters sent to the server, they don't need to be returned. iTotalRecords and TotalDisplayRecords probably should be replaced by recordsTotal and recordsFiltered. That should get you started.

    Its unclear if your Datatables columns.data structure matches the multiple levels you have in your JSON data structure.

    Kevin

  • klermannklermann Posts: 277Questions: 67Answers: 1

    I understend Kevin, can you explain to me, how does datables read the parameters sent by the server?

  • allanallan Posts: 63,356Questions: 1Answers: 10,447 Site admin

    I'm not sure what difference it makes how DataTables reads the parameters - the fact is, as Kevin points out, you aren't returning the data with the JSON parameters that DataTables is expecting.

    If you are interested in how it reads the parameters, this is the section of the code where it does. But again, I don't see that would help. Just change the parameter names to what DataTables expects.

    Allan

This discussion has been closed.