0
votes

I want to get selected value of p:column of p:datatable by using javascript(jquery). Do you think is that possible ? I tried several ways but I could not succeed. Any help will be great.

Regards

Here is the sample Code :

<p:dataTable id="attachmentsTable" var="dataRow" value="#{taslakFaturaBean.attachments}" style="width:980px; text-align:center;">
            <p:column headerText="ID">
                #{dataRow.AttachID}
            </p:column>
            <p:column headerText="Dosya Tarihi">
                #{dataRow.AttachDate}
            </p:column>
           <p:column headerText="Dosya">
                <p:commandButton id="downloadLink" value="İndir" icon="ui-icon-arrowthichk-s" rendered="#{not empty dataRow.AttachData}" ajax="false">
                </p:commandButton>
            </p:column>

I want to get selected p:column's AttachId when I click downloadLink commondButton by javascript.

1
could you give a bit more details what you want? part of the source code will be goodDaniyar
your answers are great. But does not fit what I want. I need a javascript method which gives value of what the selected at p:column.I provided sample code.Please help meTonyukuk
do you mean that you need to get the dataSlected from the datatable if yes the link that provided by Daniyar is the best way to see howYagami Light
yes Lagami. exactly . I want to do it by javascript :) Not by beans . I want to complete all the process on the frontend. I do not want to go to backendTonyukuk

1 Answers

0
votes

If you want pure javascript I think it can be by this way

<script type="text/javascript">
        function test(attachId) {
            // get attachId
        }
</script>

and in your dataTable like this

<input type="button" onlcick="test(#{dataRow.AttachID});" value="GetID" />

if you want to use commandButton you can try to use onclick="test(#{dataRow.AttachID})" but not sure about that :)