cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Pass table data using AJAX

Former Member
0 Likes
291

Hi Guys,

I am little new to the world of AJAX.

What i have to implement is, After the input from the user into an input field, I need to populate a table with data.I am doing this in AJAX but failing.

I am using HTMLB:TableView to display the data.

Please help me out with some basic code.

Regards,

Abhi

Accepted Solutions (0)

Answers (2)

Answers (2)

RieSe
Contributor
0 Likes

Hi,

at first you need an event, to send the data. The simplest thing for that, you use a htmlb-button.

A little bit trickier is to bind the on-Blur-Event to your field. OnBlur means: the user has finished

doing his entry and the focus for this leaves, i.e. the user click anywhere outside the field.

If you want to do this, take the jquery-library (jquery.com), which is free, and have a look at the documentation. The only thing, you need to know, is the id of your field.

The second thing, you have to do, is to prepare yor page with the tableviewdata. Do it like


        <%loop at itab into structure. id = sy-tabix. condense id.%>
        <htmlb:inputField id = "itab[<%= id %>].field1"              value = "<%=structure-field1%>"             visible = "false" />
                <%loop at itab into structure. id = sy-tabix. condense id.%>
        <htmlb:inputField id = "itab[<%= id %>].field2"              value = "<%=structure-field2%>"             visible = "false" />

        <%endloop.%>

and so on, assuming that your table has a structure with two fields.

For third, you can use the jquery library with their ajax function to submit these data to the remote page.

That's all. There a many posts on inet for that stuff. Goggle it. But using jquery or another library makes

this much easier.

Best regards, Stefan

athavanraja
Active Contributor
0 Likes

where are you having problem?

in AJAX or in htmlb:tableview?

check these weblogs

/people/piotr.plusa/blog/2008/01/31/ajax-with-htmlb-elements-on-bsp-pages

/people/sap.user72/blog/2005/08/15/ajax-and-htmlb--a-sample-bsp-application

/people/renald.wittwer/blog/2007/05/07/bsp-htmlb-tree-view-with-ajax

Former Member
0 Likes

Hi Durai & Stefan

Thanks a lot for your time.

I have problem in the AJAX end.I want to make the trip to server and back using AJAX during which i will populate data in the table.How to send the table from the server to view using AJAX.

@Stefan i have to use the htmlb:tableview tag.Please help me with this.

Regards,

Abhishek

Edited by: Abhi on May 18, 2009 6:06 AM

athavanraja
Active Contributor
0 Likes

your sever side app (say BSP) can read data and send result as xml and in your other BSP where you have the htmlb:tableview you have to transform this xml into itab so that you can use it with tableview

Former Member
0 Likes

Hi Durai,

Thanks a lot for the tips.I would really appreciate a simple sample program incase you have it related to this issue.

Regards,

Abhishek

Edited by: Abhi on May 19, 2009 7:20 AM