about Flex DataGrid edit
Summary(¸ÅÊö)£º Adobe Flex µÄ dataGrid ÓкÜÇ¿´óµÄ¹¦ÄÜ£¬±ÈÈçItemRenderer,headerRendererµÈ£¬¿ÉÒÔ·½±ãµØʵÏÖ×Ô¼ºÏëÒªµÄ¹¦ÄÜ¡£µ«¶ÔdataGridÖ±½Ó±à¼²¢±£´æµ½Service¶Ë£¬¾ÍÓеãÂé·³ÁË¡£
Requirement(ÐèÇó)£º ¶ÔdataGrid½øÐе¥Î»¸ñ±à¼£¬ÈôÓб仯£¬±£´æµ½Service; ·ñÔò²»±£´æ¡£
Solution(½â¾ö·½°¸): ÔËÓÃDataGrid µÄ itemEditBegin ʼþ¡¢itemFocusOut ʼþ¡£
1. when the itemEditBegin is dispatched, the event handler should save this cell value as old value.(±à¼Ç°±£´æ¾ÉÖµ)
2. when the listener of itemFocusOut is responding, you should check the current cell to the old value. If it's value have changed, you should save the new value to Service.(±à¼ºóÅжϣ¬ÊÇ·ñ¸ü¸Ä¡£)
Example(Àý×Ó) as follow:
<mx:Script>
<![CDATA[
private var oldValueOfEditedItem: CreditVO;
private function creditDGEditBegin(event: DataGridEvent): void {
oldValueOfEditedItem = (event.itemRenderer.data as CreditVO).clone() as CreditVO;
}
private function editedItemChanged(newValue: CreditVO): Boolean {
return (newValue.amount != oldValueOfEditedItem.amount)||
(newValue.description != oldValueOfEditedItem.description);
}
private function creditDGEditEnd(event: DataGridEvent): void {
var newValue: CreditVO = event.itemRenderer.data as CreditVO;
if (editedItemChanged(newValue)) {
dispatchEvent(new UpdateCreditEvent(newValue))
}
}
]]>
&
Ïà¹ØÎĵµ£º
MyEclipse FlexµÄÅäÖÃÖ®³õÎÒÃÇ¿´¿´ÔµÓÉ£ºÒ»¿ªÊ¼Ñ§Ï°Ê¹ÓÃFlexµÄʱºò,ÎÒÊÇÓõĵ¥¶ÀµÄFlexBuilder3,×öЩ´¿FlexµÄÓ¦ÓóÌÐò»¹¿ÉÒÔ.µ«ÊÇÈç¹ûÒªºÍJava½áºÏÔÚÒ»ÆðʹÓÃ,¼´ÀûÓÃFLEX³äµ±Ò»¸öÍêÕûµÄJ2EEϵͳµÄWEB²ãµÄ»°,ÄÇôµ¥¶ÀʹÓÃFlexBuilder3ºÍMYECLIPSEÊǺܲ»·½±ãµÄ,´ó´óÓ°ÏìÁË¿ª·¢Ð§ÂÊ,Òò´Ë×öÁËÏÂMyEclipse+FlexµÄÅäÖÃ,´ïµ½Ö±½ÓÔÚ ......
Ê×ÏȽ¨Ò»¸önetbeansµÄjava webÏîÄ¿
È»ºó´ÓÍøÉÏ°Éblazeds.war ÏÂÔØÏÂÀ´ÓÃrar ½âѹ °Ñweb-inf Ìæ»»µôÔÚnetbeans\web ÏÂÃæµÄweb-infÖеÄÈ«²¿Îļþ
È»ºó ²¿ÊðÏÂ
ÔÚ´ò¿ªflex builder н¨Ò»¸öflex project дÉÏÃû×ÖºÍÏîĿ·¾¶
ÔÚApplication server type Ñ¡ÖÐj2ee
µã»÷ ÏÂÒ»²½
È»ºó Root folderÑ¡ÖÐnet ......
Ò»°ãÀ´½²£¬ÔÚwindowsÉÏ°²×°Èí¼þ´ÓÀ´¶¼²»ÊÇʲôÄÑʶù£¬µ«FMSÈ´ÔÚ°²×°¹ý³ÌÖÐ"³äÂú"ÁËÎóµ¼£¨ºÃ°É£¬ÆäʵҲ¾ÍÊÇ¿äÕŵÄ˵·¨¶øÒÑ£©
1.ÏÂÔØFMS3.5
http://www.adobe.com/products/flashmediainteractive/?promoid=DJDTG
ÕâÉÏÃæÓÐÒ»¸öÃâ·Ñ¿ª·¢°æ(³ýÁËÁ¬½ÓÊýÓÐÏÞÖÆ£¬ÆäËü¹¦ÄÜÍêÈ«Ò»Ñù)
2.һ·Next°²×°
×¢ ......
ÔÚflexµÄdataGridÖУ¬ºÜ¶àÇé¿öÏÂÁÐÊÇÐèҪǶÈëÆäËûµÄ¿ØÖƵģ¬±ÈÈ磺checkbox,comboxµÈ£¬´ËʱÐèÒªÀûÓÃdataGridµÄÈçϹ¦ÄÜ£º
1.datagrid±à¼¹¦Äܼò½é
µ±ÎÒÃǵã»÷datagridÖеÄÒ»¸öµ¥Ôª¸ñ½øÐбà¼Ê±£¬¿É½áºÏʹÓÃһЩ×é¼þ£¬RadioButtonGroup¡¢checkbox¡¢ComboBoxµÈ
datagridµÄ±à¼¹¦Äܱ ......
ºÜ¶à¿ª·¢ÈËÔ±¶¼ÖªµÀÈçºÎʹÓÃʼþ»úÖÆ£¬µ«È´²»Àí½âʼþ»úÖƵĻù±¾¹¤×÷ÔÀí¡£ÔÚÕâÀïÎÒÃÇ̽ÌÖÒ»ÏÂActionScript 3µÄʼþ»úÖÆ(ÎÞÂÛÊÇÐÂÊÖ»¹ÊÇÀÏÊÖ£¬ÎÒÏàÐÅ¿´µ½×îºó¿Ï¶¨¶ÔÄãÓÐËù°ïÖú )¡£
1. Ê×ÏÈÀ´¿´Ò»ÏÂʼþ»úÖÆÖеļ¸¸ö»ù±¾¸ÅÄ
event objects(ÕâÀïÎÒÃǹÃÇÒ½ÐËüʼþ¶ÔÏó)£ºËùÓеÄʼþ¶ÔÏó¶¼ÊÇflash.events.Event»òÕßÆä×ÓÀà¡ ......