cancel
Showing results for 
Search instead for 
Did you mean: 

Check if a row is selected in TableView in javascript

Former Member
0 Kudos

Hi All,

I am working in EP5.0. I want to do client side(javascript) validation to check if a row is selected in Tableview. Since the controls(radio button) are dynamically generated how to get the name of the control? If the name is known I could use myContext.getParamIdForComponent("controlname").

Is there a way to do it?

Thanks in advance,

Priya

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
detlev_beutner
Active Contributor
0 Kudos

Hi Francisco & Priya,

the link Francisco gave is a good starting point, nevertheless, the complete JS API is - as far as I know - not documented at all, but on the other hand very, very precious.

So here comes the right name: Look at ...\irj\root\portalapps\com.sap.portal.htmlb\jslib\controls_[...].js, for example controls_ie5.js.

There for HTMLB tableview objects you will find the following methods:

getClickedRow()
getClickedRowKey()
setClickedRow()
getClickedColumn()
setClickedColumn()
getSelectedRows()
getSelectedRow()
getSelectedRowKeys()
getSelectedRowKey()

With one of them (sorry, I don't remember exactly, I think it was getSelectedRowKeys()) I had some trouble, but in general, this file with it's JS API definitions is very valuable when you want to do client side checks.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev,

The methods you have mentioned, is it in EP 6.0?

Is it possible to use these methods in EP 5.0?

Is it possible to get the values of textboxes in a cell in TableView in client side?

Thanks and Regards,

Priya.

detlev_beutner
Active Contributor
0 Kudos

Hi Priya,

> is it in EP 6.0

It's stolen from EP6 SP2 P28, to be exact.

> Is it possible to use these methods in EP 5.0?

Probably, HTLMB stuff does not change it's API very often (but the implementation, for there are some bugs at every time). But just have a look into the file given, then you will see by yourself. That's why I don't only say "Yes", "No" or "MethodName", but also where it comes from...

> Is it possible to get the values

> of textboxes in a cell in TableView

> in client side?

For sure it will be, it's a question of time and effort... To start, have a look into the rendered HTML to get an idea how it is built.

Hope it helps

Detlev

PS: Please consider awarding points for helpful answers. Thanks in advance!

Former Member
0 Kudos

Hi Detlev,

I searched for the file controls_ie5.js. But I have only one function for cell click in js file. I didnt get any methods you mentioned in the reply.

The workaround I could see is, get the name of the tableview control using 'myContext.getParamIdForComponent("tableviewcontrolname")'. Then append '-chk'(that is the name generated dynamically for the radio button in the HTML page). With this we can do a javascript validation if a radio button is selected. The only disadvantage is if they change the naming conventions(say instead of -chk if they use _chk) for HTMLB implementation this code will fail.

In another post I saw a reply from Stephan Batzdorf for similar post. He says, "Now to the client side. The only thing you can do on client-side is to retrieve the selected rows and get the values from the key column.

It's not possible to manipulate data. Of course you can render InputFields into table cells and let the user manipulate them, but then you have to retrieve each value for each InputField again on server side (pageContext.getComponentForId(tableCellInputFieldId);)."

Does he say we cant get the value of inputfield in the client side?

I will definitely award points once the problem is fixed.

Regards,

Priya

detlev_beutner
Active Contributor
0 Kudos

Hi Priya,

> Does he say we cant get the value of inputfield

> in the client side?

For sure you can!

> I will definitely award points once the problem is fixed.

I hope so (you could even if the problem isn't fixed yet, there are also points for "helpful" and "very helpful" answers which didn't "solve" the question...)

Best regards

Detlev

detlev_beutner
Active Contributor
0 Kudos

Hi Priya,

as far as I understand, the radio buttons are rendered by HTMLB by using a TableView with SingleSelection, right? In this case, what you can retrieve is the TableView JS object. For this, JS methods exist to ask which row is selected, see ie5controls.js (or so, don't have file access at the moment).

If you need further assistance, please submit is minimized example of your JSP, DynPage, or AbstractPortalComponent, depending on what you are using.

I addition, please be a bit more responsive than you have been in and Consider rewarding points for helping answers, that's the SDN way to say "thank you, good help". If proposals didn't work, also this would be nice to give as feedback information, for the people trying to help as well as for others running into the same issue.

Hope it helps

Detlev