Skip to main content

doAjax and yahoo datatable

4 replies [Last post]
nnxcoder
Offline
Joined: 2008-02-02

Hi,
I have a situation with doAjax and data tables in jmaki. I have 2 tables A and B. Upon clicking a row in A I doAjax Submit and retrieve values for table B and display it by making the containing div visible. However I need to add more information above the table indicating which row was selected and such. How can I do this?

Any help will be appreciated.

Thanks,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nnxcoder
Offline
Joined: 2008-02-02

Thanks for the answer. I was able to get it working.

bakarirum
Offline
Joined: 2005-07-07

I am glad I was able to help. Without giving away business logic, can you explain what I was able to provide that helped you. This is for my sanity and also in case someone searches the forum later and wonders what you did to accomplish your specific problem.

Thanks!

nnxcoder
Offline
Joined: 2008-02-02

I create another JSON Object with label and added it to my JSON array. The method returns a string which is parsed by the callback function as follows:

var tmp = _req.responseText;
var obj = eval("(" + tmp + ")");
var rowData = obj.arrayString;
jmaki.log(""+ rowData);
var labelData = obj.label;
jmaki.publish("/table/topic33/clear", {});
jmaki.publish("/table/topic33/addRows", rowData);
document.getElementById("displayMessage").innerHTML = labelData;

Thanks for the guidance, I have also posted another question on sorting yahoo datable, please let me know if you have any tips for that.

Thanks,

bakarirum
Offline
Joined: 2005-07-07

When you are calling doAjax, you have to specific a callback function.

In the callback function, I am assuming that you are publishing content to your DataTable B, correct?

Why not use a label in your HTML form and in the same javascript function, update the content of that label? I am also assuming that you are returning JSON from your Ajax call (which is not a requirement, but most use this). You can set up your JSON response to have two objects in it. One can be your dataTable rows item and the other can be your other content to display above the table in the label mentioned above. Below is some pseudo-code. Do not take it verbatim. I am not taking the time to look up syntax, etc. It is meant to give you direction in order to accomplish your task and do more research. The CDATA tag is only implement to allow the post to bypass any HTML formatting it might want to use so ignore those.


...

...



value="{columns: [.../>
...

]]>