You need to sign in to do that
Don't have an account?

DataTable Row numbers?
I want to have a string in each row of a data table that includes the Row number.
Payment 1, Payment 2, Payment 3, etc.
In js I would just use the row counter. Anything analogous in a VF datatable?
Thanks,
Steve
Payment 1, Payment 2, Payment 3, etc.
In js I would just use the row counter. Anything analogous in a VF datatable?
Thanks,
Steve
i've done this by building a data model that holds a row, and a row number
i access the row contents and the row number using getters.
here is a portion of my RSS feed class that does this, when building the entry ( in the controller, in a loop) i set the index
then it is available in the Visualforce page as "{!index}"
I've got a dataTable that has a list of objects as the value. My understanding is that the var is then each object.
Steve
Then in VF it's just an ouputText:
Then I just have to clean up that bogus data:
Ugly, but easy if you have a text field lying around...
I'd love to see an easier way to get row index while in a dataTable.
Thanks,
Steve
the wrapper looks something like this
Is there any way to get param to work in my dataTable?
Does param value get set on instantiation of the dataTable and doesn't call out again? That's what seems to be happening.
Thanks,
Steve
you need to have your output inside a repeat tag, and then using var="foo"
you access each member as {!foo.paymentNumber}
you still need the wrapper class to describe the data model, the payment number becomes part of your data model in the end.
I have a suggestion for any still looking to do this, that is simple and entirely visualforce tag based.
To give the rows numbers, you can simply use the <apex:variable> tag. Define the variable instance once just before the pageblock with a base value, then again inside a column in the table, this time incrementing the current value by 1 each time after the variable is used.
Here is a code example for a table of contacts related to an account:
Hope that helps,
Christopher Alun Lewis
Check out the Christopher Alun Lewis Blog for similar Salesforce tips and samples!