Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
GridView not being editable after becomming visible
posted

I have a GridView inside a panel that is set to be initially rendered as false, in the backing bean after getting the data and binding it to the grid I'm setting the panel's rendered attribute to be true.  This works fine, the grid appears with the data in it, however the column that I set up ( and need ) in the grid is no longer editable.  If the panel's rendered attribute to initialy be true everything is fine.  I'm creating most of the GridView in the backing bean.  The happens in both the ie and firefox browsers.

 

Thanks much,

Eric Bieche

 

JSF Code snippet :

<h:panelGroup style="width: 100%;" > <h:panelGrid columns="1" rendered="#{page.showGrids}" >  

<h:panelGroup > <h:panelGrid columns="1" >

       ... other stuff ....

      <h:panelGroup style="width: 20%;" >
         <ig:gridView id="totalGrid"
                      allowFixedColumns="true"
                      rowFetchSize="300"
                      loadOnDemand="default"
                      columnStyleClass="font-style: normal; font-family: Arial, Verdana, Sans-Serif;"
                      style="height: 200px; font-style: normal; font-family: Arial, Verdana, Sans-Serif; font-weight: bold;"
                      binding="#{page.totalGrid}"
                      dataSource="#{page.totalDmaData}" >

            <ig:gridEditing id="totalGridEdit"
                            enableOnMouseClick="single"
                            cellValueChangeListener="#{page.cellValueChangeListener}" />

            <ig:gridActivation id="totalGridActivation" />
         </ig:gridView>
      </h:panelGroup>
   </h:panelGrid> </h:panelGroup>

</h:panelGrid> </h:panelGroup>

 

 

The backing bean code to init the grid and create the columns looks like

 

  private void initGrid(GridView grid, ColumnMetaData [ columns) throws Exception
   {
      FacesContext context = FacesContext.getCurrentInstance();

      if(grid != null) clearGrid(grid);
     
      // These are the columns of the grid

      // loop through the meta-data defining the columns in the dataModel
      // and create a column in the grid for basic data type
      for (int index = 0; index < columns.length; index++)
      {
         ColumnMetaData columnMetaData = columns[index];
         if (columnMetaData != null && columnMetaData.getDatatype() != List.class)
         {
            Column column = null;

            boolean readOnly = true;
            // Currently there are two columns that can be edited by the user
            if( "factor".equals(columnMetaData.getName()) ||
                "finalPen".equals(columnMetaData.getName()) )
            {
               readOnly = false;
            }

            column = createColumn( context, columnMetaData.getDisplayName(),
                                   "#{DATA_ROW." + columnMetaData.getName() + "}",
                                   columnMetaData.getName(), readOnly);

            grid.getTemplateItems().add(column);
         }
      }

      grid.dataBind();
   }//End of initGrid


   /**
    *
    * @param context
    * @param header
    * @param binding
    * @param sortByCriteria
    * @param readOnly
    * @return
    */
     private Column createColumn(FacesContext context, String header, String binding,
                               String sortByCriteria, boolean readOnly)
   {
      Application application = context.getApplication();
      UIViewRoot viewRoot = context.getViewRoot();
      Column column = (Column) application.createComponent(Column.COMPONENT_TYPE);
      column.setId(viewRoot.createUniqueId());

      if (header != null)
      {
         UIOutput columnHeader = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);

         columnHeader.setValue(header);     
         columnHeader.setId(viewRoot.createUniqueId());
         column.setHeader(columnHeader);
      }

      UIOutput columnContent = new UIOutput();
      columnContent.setId(viewRoot.createUniqueId());

      // define the value binding
      columnContent.setValueBinding( "value", context.getApplication().createValueBinding(binding));
      column.getChildren().add(columnContent);

      // if there a sortBy criteria
      if (sortByCriteria != null)
      {
         column.setSortBy(sortByCriteria);
      }
     
      column.setReadOnly(readOnly);
      return column;
   }//End of createColumn

   /**
    * Clear a grid to rebind it later-on
    *
    * @param grid
    */
   private void clearGrid(GridView grid)
   {
      grid.setFooter(null);
      grid.setHeader(null);
      grid.getChildren().clear();
      grid.getTemplateItems().clear();
      grid.setColumnPositions(null);
   }//End of clearGrid

 

Parents
No Data
Reply
  • 1765
    posted
    Hi Eric, Thank you for providing code snippet. I did test the same and was unable to reproduce the issue being mentioned. Infact, I was able to 'show' and 'hide' the dynamic webgrid by triggering value in backing bean. In order to understand more regarding this issue, we greatly appreciate if you could provide us an isolated sample application with all the jsp and backing bean files. This would help us reproduce, find the root cause and provide solution at the earliest. Thank you!<h:panelGroup styleClass="section" rendered="#{dynamicGridWeb.showGrid}"><ig:gridViewbinding="#{dynamicGridWeb.grid}"dataSource="#{dynamicGridWeb.rows}"id="grid1"/></h:panelGroup> 
Children
No Data