Different renderers for datagrid in flex 4.0 -


i'm working in flex 4.0 , have data grid 3 columns. second column should display selection(s) user has made according these rules: if selected 1 name display label name in grid cell, if chose more 1 name drop down list should displayed title "multiple selected" , drop down when clicked show names associated entry. therefore second column can have mixture of labels , drop down lists. example first entry chose 1 person, first row second column shows label person's name. in second entry chose 2 names, second row second column shows drop down list 2 names in drop down list. can see second column has label , drop down list mixture. note selection process not taking place in datagrid, information being supplied means of setting dataprovider datagrid.

i figure out make itemrenderer both label , dropdown list disable 1 while enabling other when conditions met. problem approach modify width because label comes first , pushes drop down list right (even when isn't visible , beyond width of column). adjust widths of each component (setting 1 100% while other 0% depending on visible) reason when update data not change cell, if click on header change width , visibility. think because ui not commit width adjusts immediately? know it's width because if comment out width adjustments once data gets updated see change right away in datagrid. instance if have not chosen yet names of selection, cell blank. make selection of 1 person shows right away name in cell using label component. if select name data gets updated again , see in data cell space (this label thats invisible has text causes empty space) , drop down list names of ones selected , again it's effect don't have click on grid update it. here's code width adjustments uncommented:

                                protected function mxdatagriditemrenderer1_datachangehandler(event:flexevent):void                                 {                                     if(data.judgmentpart.judgmentdebtors.length ==1)                                     {//display label , disable dropdown list                                         lbldata.visible = true;                                         lbldata.enabled = true;                                         lbldata.percentwidth = 100;                                         ddldatagrid.visible = false;                                         ddldatagrid.enabled = false;                                         ddldatagrid.percentwidth = 0;                                     }                                     else if (data.judgmentpart.judgmentdebtors.length >1)                                     {                                         lbldata.visible = false;                                         lbldata.enabled = false;                                         lbldata.percentwidth = 0;                                         ddldatagrid.visible = true;                                         ddldatagrid.enabled = true;                                         ddldatagrid.percentwidth = 100;                                     }                                     else                                     {                                         lbldata.visible = false;                                         lbldata.enabled = false;                                         lbldata.percentwidth = 0;                                         ddldatagrid.visible = false;                                         ddldatagrid.enabled = false;                                         ddldatagrid.percentwidth = 0;                                     }                                 }                                  protected function mxdatagriditemrenderer1_creationcompletehandler(event:flexevent):void                                 {                                     lbldata.visible = false;                                     lbldata.enabled = false;                                     lbldata.percentwidth = 0;                                     ddldatagrid.visible = false;                                     ddldatagrid.enabled = false;                                     ddldatagrid.percentwidth = 0;                                 }                              ]]>                         </fx:script>                         <s:hgroup width="100%" verticalalign="middle">                             <s:label id="lbldata" text="{data.judgmentpart.judgmentdebtors}"                                      />                             <s:dropdownlist id="ddldatagrid" dataprovider="{data.judgmentpart.judgmentdebtors}"/>                         </s:hgroup>                     </s:mxdatagriditemrenderer> 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -