0

Below is my XML:-

<Category>
  <ID>1</ID>
  <Name>Root</Name>
  <Type>NA</Type>
  <Children>
    <Category>
      <ID>3</ID>
      <Name>Ritter Comm</Name>
      <Type>Operating Group</Type>
      <Children>
        <Category>
          <ID>5</ID>
          <Name>Product Line</Name>
          <Type>Product Line</Type>
          <Children>
            <Category>
              <ID>6</ID>
              <Name>Video</Name>
              <Type>Category</Type>
              <Children>
                <Category>
                  <ID>8</ID>
                  <Name>TV</Name>
                  <Type>component</Type>
                  <Children />
                </Category>
              </Children>
            </Category>
          </Children>
        </Category>
      </Children>
    </Category>
    <Category>
      <ID>10</ID>
      <Name>Test_Changeset</Name>
      <Type>Operating Group</Type>
      <Children>
        <Category>
          <ID>11</ID>
          <Name>Changeset</Name>
          <Type>Product Line</Type>
          <Children />
        </Category>
      </Children>
    </Category>
  </Children>
</Category>

I want to generate a tree view structure in Visualforce Page like below:- -Root -Ritter Comm -Product Line -Video -TV -Test_Changeset -Changeset

I'm using apex:repeat, but how we will know for how many times the apex:repeat tag to be used based on the level depth? Any ideas much appreciated!!!

1

You have a few options:

  1. Using dynamic VF in Apex (traverse through the XML and generate components as you hit leaf nodes)
  2. Using Javascript/jQuery in VF (process the XML directly on the client side)
  3. Or maybe this: http://www.forcetree.com/2011/04/tree-view-in-visualforce-page.html
2
  • Thanks... in that link the level of hierarchy is fied - Account,Contact Last name & Cases.
    – Ashish
    Apr 14 '15 at 4:55
  • But in this scenario it varies dynamically.How we will take care of that?
    – Ashish
    Apr 14 '15 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.