Wt setting Grid model through AJAX
Added by Dinu Ajikutira over 14 years ago
Hi All,
I am trying to implement an EXT Grid, the column and rows of which are configured by the server at run time and can change dynamically. The way I have done this in the past (while working with Python webserver) is by creating a EXT grid and using its ColModel property (EXT 3.0) and then setting the ColModel.SetConfig to a configuration received through AJAX from the server. This is repeatedly updated as the state of the client changes.
Can I do this in Wt? I understand EXT 3.0 is not supported, but I will need the functionality where the configuration of a UI element will change depending on user inputs, and the change can only be configured from the server (because the change is a result of numerical calculations). Let me give a simple example:
1. I have a grid which can have 3 columns (A, B, C) and 3 rows (1, 2, 3).
- If the user enters 10 into A1, the A2 is disabled for user entry and column C is not visible.
- If the user now enters B1, then A3 and B2 become disabled.
You get the idea... And the interaction has to be done through AJAX. If I can do this with Wt, can you please set me up with an example or give me an idea how I can accomplish this? where should I set breakpoints to see how this works in Wt?
Thanks
-Dinu
Replies (4)
RE: Wt setting Grid model through AJAX - Added by Koen Deforche over 14 years ago
Hey Dinu,
With Wt, everything you do is automatically using AJAX. You simply react to events and call the respective methods of the Wt API. This makes it ideal for your use case where the change depends on server-side calculations. Any Wt example, starting with hello world, demonstrates this.
Coming from the JavaScript/ExtJS world, this is a rather drastic difference: with Wt, everything is determined on the server-side and you do not need to prepare your interface to have certain changes done through AJAX --- during an event you can change anything.
Regards,
koen
RE: Wt setting Grid model through AJAX - Added by Dinu Ajikutira over 14 years ago
Thanks Koen,
I am guessing that I can also have the java scripts handle some events as well and that way I dont have to make the server round trip when not necessary.
-Dinu
RE: Wt setting Grid model through AJAX - Added by Koen Deforche over 14 years ago
Hey Dinu,
Yes, but there is no JavaScript API for complex operations like loading model data. But you can do simple plain DOM things using JSlot and doJavaScript(). In our experience you will do this only for a very small fraction of your events and the amount of JavaScript you typically write is very limited.
Regards,
koen