Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    reordering tiles in tilegrid with custom tiles

    I'm trying to do a few probably unrecommended things with tile grid.

    First I'm creating custom tiles with getTile(), and that works ok, but if I try to reorder these custom titles, I get a type error is null on the movement (unnamed(isc_TileLayout_showDragLineForRecor) @ admit/sc/modules/ISC_Grids.js). Also when it's time to rewrite the tiles, the resultset hasn't changed order.

    Here is the code for that:
    Code:
    new TileGrid(){{
        setCanReorderTiles(true); 
        setShowAllRecords(true);  
        setDataSource(new DataSource(...));  
        setAutoFetchData(true);     
        setTileWidth(100);
        setTileHeight(100);
        }		
    
        @Override
        public Canvas getTile(int index){		
            final Record record = getResultSet().get(index);
            return new Canvas(){{
            addChild(new Label("pardon " + record.getAttributeAsInt("id")));
        }};
    }
    A second crazier thing that I haven't gotten much into is different size tiles(setLayoutPolicy(TileLayoutPolicy.FLOW) might do it), with a snap to grid. Essentially you have an ordered list of tiles that you can resize and it will snap to the grid while moving the other tiles around. I think the layout policy flow will help me on that. If you have any recommendations on this second bit, I'd be very grateful.

    #2
    I found that the canvas from the getTile super method is required for the reordering. By calling the super method and adding an item saved in a hashmap to the super method's canvas, you can customize the tile beyond detail viewer fields, while still allowing reordering.

    About the differing size tiles for grid layout, I found it was possible with layoutPolicy of flow, but it generates this message in the log:
    [ERROR] [admit] - 15:16:30.982:XRP3:WARN:Log:TileGrid does not support layoutPolicy 'flow'; there may be unexpected behavior. Use a TileLayout instead for flow layout.
    Does Isomorphic know what the unexpected behavior could be, or is it just a "we didn't test it"?

    Comment


      #3
      There's no way to do rendering / loading on demand with a layout of "flow". Given a scroll position, you have no idea which range of tiles to render because you don't know how many tiles appear above the current scroll position without rendering them all.

      Comment


        #4
        I understand why everything would need to be rendered again, but this may not be a problem for us.

        (1) We're going to have at most 8 items in the layout
        (2) the content of the tiles is cached, so the only thing being rendered is the new canvas. The stuff being added to super getTile canvas, we've already cached.
        (3) Lastly, the idea behind this is that rarely would people actually reorder, which would cause the rendering.

        Is there anything we haven't taken in to account?

        Comment


          #5
          If you've got a small fixed set of tiles, just use TileLayout not TileGrid.

          We couldn't tell you what you might run into using TileGrid in a mode it's not designed to support, but if you did run into something, it wouldn't be considered a bug, and if your code broke in the future, that wouldn't be considered a regression..

          Comment


            #6
            Part of the appeal of tilegrid is the way it's databound. For example, there's a setdatasource and autofetch. TileLayout doesn't appear to have any notion of a record, so when we do need to be able to interact with tile more dynamically we seem to be out of luck.

            Is there some way to interact with TileLayout more intelligently with data, rather than simple calling addtile multiple times?

            Comment


              #7
              DataSource.fetchData() plus a loop of creating your tiles in the callback is pretty much going to be less code, or trivially more code, as compared to your current strategy of overriding getTile() and storing things in a Map for later re-use.

              Comment


                #8
                I was able to implement the gettile strategy to allow reordering with custom tiles with tilegrid. The original goal of all of this was reordering of tiles, which was part of the reason I chose tilegrid.

                I see that tilelayout has: setAnimateTileChange, but I don't see a way to reorder the tiles, save removing and re-adding, and then dragging and dropping is a whole separate issue. TileLayout doesn't seem to have any of these capabilities. Is there some way to simplify this as opposed to creating drag and drop reordering from scratch?

                Comment

                Working...
                X