Grid problem wiping when frozenColumnCount>1

I’m using Scaladin against 7.4.5

I have a button that runs following code, which runs just fine the first time, gives me 2 frozen columns.

If I click button again I only see 1 column, rest are invisible! Refreshing page will show them all

Running in ?debug mode I get a client side exception on the second fill()

Now if I set the frozenColumnCount to 1, it works with no problem

Its quite possible that I’m doing things wrongly, as the Grid docs are a tad sparse. I do find it odd that I only see
a problem if frozenColumnCount>1 (unfortunately I need it in my app)

Thanks.

def fill2()={
container.removeAllItems()
removeAllColumns()

     val propids=container.propertyIds.map(identity)
     propids.foreach{container.removeContainerProperty}
     
     addColumn("Area")
     
     val localDate=java.time.LocalDate.now()        
     (0 to num).foreach{v=>val dat=localDate.plusDays(v);addColumn[java.lang.Double]

(dat)}

     val item = container.getItem(container.addItem()) 
     item.getProperty("Area").value="A big label3 "+localDate         
     item.getProperty(localDate).value=1.0
              
     frozenColumnCount=2                  
     p.recalculateColumnWidths()         
    }

Hi,

With a quick glance I’d guess that the issue is removing columns so there are fewer columns than there are frozen columns. For me it feels like a bug in the Grid (possibly a too strict assertion that could be relatively easily fixed). I couldn’t quickly figure a workaround for that issue, basically you’d need to do that change with multiple parts or do a container change with something like this

// This is basicly the container parts of the code you posted
Container.Indexed container = createNewContainer();
grid.removeAllColumns();
grid.setContainerDataSource(container);

Although I’m not sure if that alone is enough to bypass the frozen column issue.

If you can make simple test case for us and file a ticket, it would speed up our debugging and fixing progress. I can post the ticket for you if you don’t want to.

// Teemu

Here’s a simple test case in Scaladin.

Come up fine. Press “Fill2” works fine. Press it again, doesn’t.

If you run with ?debug then you get a client side exception. Note, its fine if frozen columns is 1.
I tried setting frozenColumnCount=0 at start of fill2(), made no difference.

import vaadin.scala._

class BadUI extends UI(title = “Bad”,theme=“valo”,preserveOnRefresh=true) {

val main=new VerticalLayout{
  spacing=true
  margin=true
        
  val grid=new Grid{
    caption="A grid"
    width=Measure(100,Units.pct)
    
    val num=40
    
    def fill()={
     println("Fill")

     container.addContainerProperty("Area", classOf[String]

, None)

     val item = container.getItem(container.addItem()) 
     item.getProperty("Area").value="A big label"
     
     p.recalculateColumnWidths()         
    }
     
    def fill2()={
     container.removeAllItems()
     removeAllColumns()
     
     val propids=container.propertyIds.map(identity)
     propids.foreach{container.removeContainerProperty}
     
     addColumn("Area")
     
     val localDate=java.time.LocalDate.now()        
     (0 to num).foreach{v=>val dat=localDate.plusDays(v);addColumn[java.lang.Double]

(dat)}

     val item = container.getItem(container.addItem()) 
     item.getProperty("Area").value="A big label3 "+localDate         
     item.getProperty(localDate).value=1.0
              
     frozenColumnCount=2                  
     p.recalculateColumnWidths()         
    }

    fill()       
  }
  
  add(grid)
  add(Button("Fill2", grid.fill2()))              
}

 content = main    

}

The problem with the frozen columns is that if you change it to something and back in one round trip, it will not actually change. You could temporarily test with a button that sets only the frozen column count to 0. then you click the other one that will repopulate the grid. If it still happens, then it’s something I can’t immediately tell.

I will try at some point running some basic debugging on that to see where and why exactly it fails. Will also post the ticket to Trac and give you the link, so you can subscribe to the issue.

//Teemu

Yes, I add a button

add(Button(“set Frozen to 0”, grid.frozenColumnCount=0))

Click Fill2, then set Frozen to 0, click Fill2 again, works fine.

Odd that it works with no problem if frozenColumnColumn is 1.