1. #1
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default Unanswered: Grid inside a Dialog - how do I get automatic sizing?

    Unanswered: Grid inside a Dialog - how do I get automatic sizing?


    All,

    Ok, I've been playing around with the Grid class (other threads I've started touch on this), and I'm working with a class I have that extends Dialog.

    Now, in that Dialog class, I call add(myContentPanel).

    The contentPanel has previously called setWidget(myGrid).

    When I show and center the dialog, the width is enough to accommodate everything horizontally (and it's quite a wide grid). However, the height is just enough to show the header row, and 1-1/2 rows after that. I have to manually resize the dialog in order to see everything vertically.

    I do not know ahead of time how many rows there will be. However, I would like the dialog to accommodate as many as realistically possible - and I guess a vertical scroll bar should automatically appear after a certain number of them, or say when the dialog has reached, say, 75% of the vertical resolution of the browser window.

    Is this something that's easily accomplished? What am I missing? Do I have to explicitly set the dialog's size in pixels in order to do what I want?

  2. #2
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    239
    Answers
    4
    Vote Rating
    2
    gishmo is on a distinguished road

      0  

    Default


    I personally prefer using VerticalLayoutContainers.

    I would try this:
    vlc.add(yourGrid, new VerticalLayoutData(1, 1));

    This work for me.

    Frank

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default


    No luck with that - using that caused the height of the dialog box to ONLY show the header row, none of the data rows.

    Further, when I stretched things out, this method also lost the scrollbars that would appear normally when I would use the RowExpander (my first column is a RowExpander).

    I have also tried using -1 as the height, to no avail.

  4. #4
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    239
    Answers
    4
    Vote Rating
    2
    gishmo is on a distinguished road

      0  

    Default


    post your code please.

    a testcase would be fantastic!

  5. #5
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    139
    Vote Rating
    4
    jvahabzadeh is on a distinguished road

      0  

    Default


    Here are the classes involved. My apologies, I've never quite figured out how to do JUnit test cases when I want to test GUI objects with GWT/Sencha.

    But with all this, you can just copy/paste directly and see what symptoms I'm describing.


    SenchaGridInDialog:
    PHP Code:
    public class SenchaGridInDialog implements EntryPoint {

      public 
    void onModuleLoad() {
        
    UserOnDayDialog dialog = new UserOnDayDialog();
        
    dialog.show();
        
    dialog.center();
      }

    UserOnDayDialog (the main class involved):
    PHP Code:
    public class UserOnDayDialog extends Dialog {

      private final static 
    DateTimeFormat TIME_SLOT_FORMAT DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE);

      private final static 
    int DEFAULT_EARLIEST_SLOT_IN_MINUTES 60// 8:00am
      
    private final static int DEFAULT_LATEST_SLOT_IN_MINUTES = (16 60) + 30// 4:30pm
      
    private final static int DEFAULT_SIZE_OF_SLOT_IN_MINUTES 30;

      private 
    ContentPanel contentPanel;
      private 
    Grid<UserInfouserGrid;

      public 
    UserOnDayDialog() {
        
    contentPanel = new ContentPanel();
        
    userGrid createUserGrid();
        
    contentPanel.setHeaderVisible(false);
        
    VerticalLayoutContainer vlc = new VerticalLayoutContainer();
        
    vlc.add(userGrid, new VerticalLayoutData(11));
        
    contentPanel.setWidget(vlc);
        
    add(contentPanel);
        
    setModal(false);
        
    setClosable(true);
        
    setOnEsc(true);
        
    setPredefinedButtons(new PredefinedButton[0]);
      }

      private 
    Grid<UserInfocreateUserGrid() {
        @
    SuppressWarnings("deprecation")
        
    Date date = new Date("4/13/2012");
        
    RowExpander<UserInforowExpander = new RowExpander<UserInfo>(new IdentityValueProvider<UserInfo>(), new UserOnDayExpanderCell());
        List<
    ColumnConfig<UserInfo?>> list = new ArrayList<ColumnConfig<UserInfo, ?>>();
        list.add(rowExpander);
        ColumnConfig<UserInfo, UserInfo> columnConfig;
        AbstractCell<UserInfo> cell;
        columnConfig = new ColumnConfig<UserInfo, UserInfo>(new UserInfoProvider(), 300);
        columnConfig.setCell(new UserSummaryCell("DAVID"));
        columnConfig.setMenuDisabled(true);
        list.add(columnConfig);
        Date time;
        for(int timeSlot = DEFAULT_EARLIEST_SLOT_IN_MINUTES; timeSlot <= DEFAULT_LATEST_SLOT_IN_MINUTES; timeSlot += DEFAULT_SIZE_OF_SLOT_IN_MINUTES) {
          time = new Date(date.getTime());
          addMinutesToDate(time, timeSlot);
          cell = new UserOnDayTimeSlotCell(time);
          columnConfig = new ColumnConfig<UserInfo, UserInfo>(new UserInfoProvider(), 50, TIME_SLOT_FORMAT.format(time));
          columnConfig.setCell(cell);
          columnConfig.setSortable(false);
          columnConfig.setMenuDisabled(true);
          list.add(columnConfig);
        }
        ColumnModel<UserInfo> columnModel = new ColumnModel<UserInfo>(list);
        List<UserInfo> userInfoList = getUserInfoList();
        Collections.sort(userInfoList);
        ListStore<UserInfo> listStore = new ListStore<UserInfo>(new UserInfoModelKeyProvider());
        listStore.addAll(userInfoList);
        Grid<UserInfo> grid = new Grid<UserInfo>(listStore, columnModel);
        grid.setBorders(true);
        grid.getView().setStripeRows(true);
        grid.getView().setColumnLines(true);
        rowExpander.initPlugin(grid);
        return grid;
      }

      private List<UserInfo> getUserInfoList() {
        List<UserInfo> info = new ArrayList<UserInfo>();
        info.add(new UserInfo("WILLIAM", "UNLIMITED", "1230", "1430"));
        info.add(new UserInfo("MICHAEL", "RESTRICTED", "1000", "1300"));
        info.add(new UserInfo("DAVID", "UNLIMITED", "0930", "1500"));
        info.add(new UserInfo("OSCAR", "RESTRICTED", "1500", "1600"));
        return info;
      }

      @SuppressWarnings("deprecation")
      private void addMinutesToDate(Date date, int minutesToAdd) {
        date.setMinutes(date.getMinutes() + minutesToAdd);
      }

    UserOnDayExpanderCell:
    PHP Code:
    public class UserOnDayExpanderCell extends AbstractCell<UserInfo> {

      @
    Override
      
    public void render(com.google.gwt.cell.client.Cell.Context contextUserInfo valueSafeHtmlBuilder sb) {
        
    sb.appendHtmlConstant("<b>User:</b> " value.getUserId() + "<br />");
        
    sb.appendHtmlConstant("<b>Status:</b> " value.getStatus());
      }

    UserOnDayTimeSlotCell:
    PHP Code:
    public class UserOnDayTimeSlotCell extends AbstractCell<UserInfo> {
      
    String timeSlot;

      public 
    UserOnDayTimeSlotCell(Date timeSlot) {
        
    this.timeSlot DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE).format(timeSlot).replaceAll("[^0-9]""");
      }

      @
    Override
      
    public void render(com.google.gwt.cell.client.Cell.Context contextUserInfo valueSafeHtmlBuilder sb) {
        if(
    value != null) {
          
    boolean isDuringLoggedInTime = (timeSlot.compareTo(value.getStartTime()) > -1) && (timeSlot.compareTo(value.getEndTime()) < 0);
          
    sb.appendHtmlConstant(isDuringLoggedInTime "<div style='width:100%;height:100%;background-color:red'>&nbsp;</div>" "");
        }
      }

    UserSummaryCell:
    PHP Code:
    public class UserSummaryCell extends AbstractCell<UserInfo> {

      private 
    String userId "";

      public 
    UserSummaryCell(String userId) {
        
    this.userId userId;
      }

      @
    Override
      
    public void render(com.google.gwt.cell.client.Cell.Context contextUserInfo valueSafeHtmlBuilder sb) {
        if(
    value != null) {
          
    boolean isLoggedInUser value.getUserId().equals(userId);
          if(
    isLoggedInUser) {
            
    sb.appendHtmlConstant("<b>");
          }
          
    sb.appendEscaped(value.getUserId());
          if(
    isLoggedInUser) {
            
    sb.appendHtmlConstant("</b>");
          }
        }
      }

    UserInfo:
    PHP Code:
    public class UserInfo implements Comparable<UserInfo> {

      private 
    String userId "";
      private 
    String status "";
      private 
    String startTime "";
      private 
    String endTime "";

      public 
    UserInfo(String userIdString statusString startTimeString endTime) {
        
    this.userId userId;
        
    this.status status;
        
    this.startTime startTime;
        
    this.endTime endTime;
      }

      @
    Override
      
    public boolean equals(Object o) {
        
    boolean result false;
        if(
    instanceof UserInfo) {
          
    UserInfo other = (UserInfo)o;
          
    result userId.equals(other.userId) && (status == other.status);
        }
        return 
    result;
      }

      @
    Override
      
    public int compareTo(UserInfo o) {
        
    int result 0;
        
    result startTime.compareTo(o.startTime);
        if(
    result == 0) {
          
    result endTime.compareTo(o.endTime);
          if(
    result == 0) {
            
    result userId.compareTo(o.userId);
          }
        }
        return 
    result;
      }

      @
    Override
      
    public int hashCode() {
        return 
    userId.hashCode();
      }

      public 
    String getStatus() {
        return 
    status;
      }

      public 
    void setStatus(String status) {
        
    this.status status;
      }

      public 
    String getStartTime() {
        return 
    startTime;
      }

      public 
    void setStartTime(String startTime) {
        
    this.startTime startTime;
      }

      public 
    String getEndTime() {
        return 
    endTime;
      }

      public 
    void setEndTime(String endTime) {
        
    this.endTime endTime;
      }

      public 
    String getUserId() {
        return 
    userId;
      }

      public 
    void setUserId(String userId) {
        
    this.userId userId;
      }

    UserInfoModelKeyProvider:
    PHP Code:
    public class UserInfoModelKeyProvider implements ModelKeyProvider<UserInfo> {

      @
    Override
      
    public String getKey(UserInfo item) {
        return 
    item.getUserId();
      }

    UserInfoProvider:
    PHP Code:
    public class UserInfoProvider implements ValueProvider<UserInfoUserInfo> {

      @
    Override
      
    public UserInfo getValue(UserInfo object) {
        return 
    object;
      }

      @
    Override
      
    public void setValue(UserInfo objectUserInfo value) {
      }

      @
    Override
      
    public String getPath() {
        return 
    null;
      }


Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi