Flex's itemrenderer problem when sorting on datagrid

149 views
Skip to first unread message

vyongjay

unread,
Jul 25, 2011, 11:43:35 AM7/25/11
to flex_...@googlegroups.com

Please follow my explanation here :

1. I have a datagrid which holds a dataprovider that has 3 columns
2. one of those 3 columns is button itemrenderer, others are integer
3. After implementing the grid, I put 4 rows into the grid
4. Then I set a button in one row to disable, others are enabled
5. Then I try sorting the datagrid by click on the column header that has
integer column (not button column). So it should be sorted by some number in
other column.

6. The expected result is that the disable button should go with its
initial row. But the actual result is that when you click to sort about 2-3
times, the buttons (in all rows) will have a wired behavior. The disabled
button sometimes turn back to enable, and sometimes turn to disabled but
stay on a wrong row.

Is there anyone got a solution on this??
--
View this message in context: http://old.nabble.com/Flex%27s-itemrenderer-problem-when-sorting-on-datagrid-tp32132877p32132877.html
Sent from the Flex India mailing list archive at Nabble.com.

Akki

unread,
Jul 26, 2011, 11:20:30 PM7/26/11
to Flex India Community
Problem seems to be with get/set data (if used by you) in item
renderer. Most probably you have put one condition in set data to set
some particular characteristic but have forgot else case to undo that.
I hope you know that flex create a pool of itemrenderers and reuse
them. If you can post the code it will be easy to fix.

Thanks,
Akhil
> View this message in context:http://old.nabble.com/Flex%27s-itemrenderer-problem-when-sorting-on-d...

Ranjit

unread,
Jul 28, 2011, 4:51:58 AM7/28/11
to Flex India Community
Hi

Its not good idea to use state in itemRenderer reason being the
itemRenderer position is not changed,
its just data which is changed.
If you keep button state with data object, your problem will be
solved.

so for Example:

data:
data.id
data.num
data.enabled

renderer:

<render>
<button enabled="{data.enabled}" />
</render>

Hope that helps

Regards,
Ranjit
> View this message in context:http://old.nabble.com/Flex%27s-itemrenderer-problem-when-sorting-on-d...

xelf

unread,
Jul 28, 2011, 5:18:57 AM7/28/11
to flex_...@googlegroups.com
Hi,
 If both of the above solutions doesn't work, then there is another option.
 
Write a function to enable\disable the buttons and call it after the sorting of the column is done using some handler to track the changes in dataprovider.
 
Thanks,
Sam
 

PRAVEEN CHOWDARY RAMINENI

unread,
Jul 29, 2011, 9:06:42 AM7/29/11
to flex_...@googlegroups.com
Hi,
check whether ur itemrenderer is placed in container like canvas, vbox or hbox.
 
--
With Regards,
PRAVEEN. RAMINENI

http://praveenramineni.webs.com/




--
You received this message because you are subscribed to the Google Groups "Flex India Community" group.
To post to this group, send email to flex_...@googlegroups.com.
To unsubscribe from this group, send email to flex_india+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.




Reply all
Reply to author
Forward
0 new messages