• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I update table using postJSON

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does anyone has code snippets for updating tables using postJSON


 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you use postJSON for such a task? And, you haven't really said anything about what you are trying to do or what problems you are having. Also, please do not post JSP markup in an HTML forum -- it's meaningless in this context.

Please put as much effort into making your posts as you would like people to take in answering them.
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My technology stack consists of Spring MVC 3.0 and it has a lot of support for postJSON. I have used a combination of jQuery/postJSON for some transactions like displaying combobox downdrop values and such.

Using the same wiring I was able to load data from the server into the client for loaded my jQuery datatable which already has preloaded data but I was unable to update the Spring items in the table and refreshing the table with new values.

Sorry about the jsp code fragments here. It was just to show where I was planning to use the javascript code. I can post this in the jsp forum if it makes more sense there.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. If it's a client side issue, it should be posted here, but with the generated client-side HTML. JavaScript doesn't know anything about the JSP markup.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jay Abrahm wrote:My technology stack consists of Spring MVC 3.0 and it has a lot of support for postJSON. I have used a combination of jQuery/postJSON for some transactions like displaying combobox downdrop values and such.



Just because there is a lot of support for something, doesn't mean you should go out of your way to use it. Using postJSON for something like select values (HTML has no such thing as a dropdown) makes sense. Simple key/value pairs of data. But for something more complex, like a table, it is a lot easier to return HTML fragments. For example, on an application I am working on I have a table...



I issue an Ajax request to the server where my controller simply forwards the request to the JSP that renders my table row:



Then I just use the jQuery's append() method to add it to my TBODY element. Really simple and zero manual processing of data on the client. If you're needs a more complex then I highly recommend something like jqGrid.
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Gregg Bolinger -- Thanks, I did just that. jQuery build up html fragments. I just need to clear up some bugs in the code and I should be all good.




1. After adding new rows the html table is no longer recognized as a data table.
2. If I duplicate the datatable initialization code, I get a error message that it is already initialized.
3. I need to add logic to add new rows (which I dont think is too difficult)

Thanks


 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahhhh, new information. Are you using a dataTable plugin? If so, then absolutely adding rows to it might make it not work. The plugin should have a means for you to add rows through it's API. If it doesn't then you need to find a better plugin.
 
Jay Abrahm
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not that I withheld info :-). I just started using it then since it had a feature that I was looking for (a slick search on table data).

Mostly, javascript is all about looking in the right direction. I tried to persist with using the html fragments but you were right I had to use the API to add rows....

Thanks again Gregg .... It all looks good !!

 
reply
    Bookmark Topic Watch Topic
  • New Topic