Tuesday, April 2, 2013

Visualforce : Using Maps in PageBlockTables...

So I had never used a Map in a PageBlockTable before. Today I did. I'll reference this Blog, since this is where I stumbled on the info. Harshesh's Blog Apparently the key is to use Value[var] to access the data in the map, within the visualforce pageblocktable. Here is an example:

     
            
           
     

if you are using a custom class in your controller or extension then it would look something like this:

Now, why would you want to do this? I'll give you a full blown example here. Let's say you want to do some work on the selected row and you need the whole rows data: ..will update later with this!

2 comments:

  1. Hi, i am getting an error "Map key not found in map". code in apex colum myMap[key].fieldname

    ReplyDelete
    Replies
    1. Hey Kalyan, if sounds like you may have a wrong type for your map key or for some reason the key doesn't exist. is your map empty? What type are you using and can you post your controller code please?

      Delete