You need to sign in to do that
Don't have an account?
hamayoun65
Radio Buttons in data table
Hi
I want to create a table which has, as it's last column, a radio button so that the user can select one item from the table. So in this example fro the user guide:
I want to create a table which has, as it's last column, a radio button so that the user can select one item from the table. So in this example fro the user guide:
<apex:page controller="dataTableCon" id="thePage">
<apex:dataTable value="{!accounts}" var="account" id="theTable" rowClasses="odd,even" styleClass="tableClass">
<apex:facet name="caption">table caption</apex:facet>
<apex:facet name="header">table header</apex:facet>
<apex:facet name="footer">table footer</apex:facet>
<apex:column>
<apex:facet name="header">Name</apex:facet>
<apex:facet name="footer">column footer</apex:facet>
<apex:outputText value="{!account.name}"/>
</apex:column>
<apex:column>
<apex:facet name="header">Owner</apex:facet>
<apex:facet name="footer">column footer</apex:facet>
<apex:outputText value="{!account.owner.name}"/>
</apex:column>
</apex:dataTable>
I want to add one more column and out a radio button in it, so that the user can select one Account. But there is no 'inputRadio' apex tag. There is a 'inputCheckbox' radio tag, but I want it to be a radio button.
Any ideas?
Thx,
Hamayoun
</apex:page>
What is the value of the "onclick" atrribute? Is it JavaScript itself, or the name of a JavaScript function? If it's the latter, can we pass parameters into the function? And how do you pull in a JavaScript snippet into a VF page?
Thx,
Hamayoun
Hi hamayoun65. Take a look at the code I posted in this message. I think it does exactly what you want: http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=2833
There is an inputCheckbox in the left-most column of each row. The javascript function in the page insures that only one row is selected at a time.
The basic functionality of having a single-select checkbox in a column of the datatable is working. The problem I was having in my original post was trying to respond to user selection by updating a different part of my page depending on which row was selected. Hope this helps.
TLF
My underlying data has a row that was already selected before the table is displayed for the first time (the primary flag). As a result, if I select another row, the original row is NOT deselected. Obviously the "selectedChkBox" variable is not initialized when the table is initially rendered.
Any ideas? I would like to initialize the selectedChkbox variable when the table is first loaded.
I want the same as you have asked in your post.
I am using PageBLockTable to dispaly more than one record.
And User have to select one record to process further.
But in VF, redio button can't be used with PageBlockTable, So I have to use inputCheckBox which I have used.
Now, how I can be able to select only one record using inputCheckBox using JS?
Can anybody help me??
Here is my Code::
I think you just need to add something like the preceding code to your page.
I believe , its still possible with using input type radio button.
1. Create input type radio buttom under apex:column for the data/ pageblock table
2. Create a apex:hidden field which will bind to the controller variable with some id.
3. Write an onclick event on the radio button, wherein you would pass the id of the record and set it onto the hidden field.
4. Let the request go to the server. It would always take the latest value bind with the variable.
Let me know in case if you face any issues.
Cheers
JJ