function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to create columns dynamically ?


I created one object, which have fields like Start date, weeks etc.,. and also i created one custom button named as "Add". 


Coming to my requirement, if i give start date as 6/11/2012 and weeks as 3 then click on add button i want to show the pageblock table with below columns


startdate , weeks, 6/11/2012, 13/11/2012, 20/11/2012. and also these 3 week values will be in input form.


here my main intention is, how to create these type of columns dynamically? and also how to take the week values

 because if i take week value as 5 then i want to populate the coloumns 5 times dynamically. so here main thing is weeks  and startdate. based on weeks i want to populte the columns. if i give 5 weeks then i want first column as start date and remaining 4 columns will populate with further week values. And also another thing is, after giving these values where i want to store the values. For this waht i want to create???


So please give the solution to me ASAP. 





Ritesh AswaneyRitesh Aswaney

You can create a Wrapper (View) Class, which has a StartDate, End Date and a List<Date> to hold the week start dates.


Its is not clear if you just want to display the weeks, or persist values against each.


You can <apex:repeat> to dynamically render Weeks by iteating over the List<Date> (Weeks) variable from the wrapper class.


You probably need to provide more detail about the use of this to be able to recommend more concrete suggestions.