Top left cell selected by default depending on source data type

Posted by: marooned on 14 September 2017, 12:00 pm EST

    • Post Options:
    • Link

    Posted 14 September 2017, 12:00 pm EST

    Hi there

    We are using FlexGrid in our product and I’ve noticed something which looks like a bug.

    When I supply CollectionView as a itemsSource, no cell is selected by default.

    When I however do this:

    <div *ngFor="let data of observableList | async">
      <wj-flex-grid [itemsSource]="data"></wj-flex-grid>
    </div>

    For each grid top left cell is selected.

    How come different data source do this and how to avoid this? Currently my workaround looks ugly and probably have some impact on performance:

    private gridDataArr = new ObservableArray()
    private gridData = new CollectionView(this.gridDataArr);
    ngOnInit() {
      this.gridDataArr.beginUpdate();
      this.gridDataArr.clear();
      this.gridDataArr.push(...data);
      this.gridDataArr.endUpdate();
    }

    And then in template

    <wj-flex-grid [itemsSource]="gridData"></wj-flex-grid>


    So in other words, I’m getting the data and add it to ObservableArray (haven’t found better way than clear/push).

    And while I’m already here, additional question. Is there an easy way to allow regular selecting? So that user can click and drag a mouse, just like selecting any text on a webpage?

    Thanks in advance.

  • Posted 14 September 2017, 12:01 pm EST

    Hello,

    We are investigating on this issue and let you know by tomorrow.

    Thanks,

    Manish Kumar Gupta

  • Posted 14 September 2017, 12:01 pm EST

    Hello,

    As per understanding, you are trying to pass an observable array in CollectionView and bind it to FlexGrid. Now the problem that you are facing is that no cell is getting selected.

    If yes, we are sorry , we are unable to replicate issue at our end with latest build that can be downloaded from here.

    For your reference, please see the attached sample that implements the same.

    If issue persists, please elaborate your requirement and modify attached sample depicting your issue so that we can assist you accordingly.

    *Please install required package before running the sample using npm install command.

    Thanks,

    Manish Kumar Gupta

    2017/04/FlexGrid_observableArray.zip

  • Posted 14 September 2017, 12:01 pm EST

    Thank you for your example. Well, the issue is that the cell is selected. And what is even stranger, in your example even with CollectionView top left cell is selected by default (so opposite as with my project).

    So ok, having your example can you alter it so no cell is selected by default? That’s my issue but in my code switching from regular array to your CollectionView fixed it (no cell is selected by default) but I would like to stay with regular array (taken from observable) but then I have this top left cell selected.

    We are using Wijmo 5.20163.254 and generally not really able to easily update if that would change anything.

    And… any comment on my second question in the first post?

    Thanks for the support.

  • Posted 14 September 2017, 12:01 pm EST

    Hello,

    You can show FlexGrid without any selection using ObservableArray as itemsSource by setting FlexGrid’s collectionView.currentItem to null.

    Regarding your second question,

    There is no direct way for the same. For this you need to use input element inside cells to display/allow select text as regular webpage.

    You need to use FlexGridCellTemplate customizing the cell and need to modify CSS.

    For your reference, please see the attached sample that implements the same.

    PS: The sample is created using 5.20171.282 and code will work same as 5.20163.254.

    Thanks,

    Manish Kumar Gupta

    2017/04/FlexGrid_selectTextFromCell.zip

  • Posted 14 September 2017, 12:01 pm EST

    Looks like we can’t understand each other.

    When I switch to ObservableArray/CollectionView then I do not have top left cell selected by default (hence my surprise that it’s selected in your example - different Wijmo version?). But then I have to use this ugly workaround that I can’t just pass a simple array directly in template. I have to get data from that array and push it to ObvervableArray and then use CollectionView as a source. So it’s just unnecessary step that slows it down (I can have thousands of records) only to have cell not selected. And I had to enable cell selection only because FlexGrid does not allow just regular selection of the content (second question) which is a bug in my opinion.

    So, anyway, looks like you can’t help me and this ugly workaround has to stay.

    Anyway, thanks for your time!

  • Posted 14 September 2017, 12:01 pm EST

    Hi,

    We apologize for the inconvenience caused.

    Let me explain some points here:

    In FlexGrid, first cell will be selected by default either is bind to array,observable array or collection view. In order, you can make default selection to null using following ways:

    1. If itemsSource is array:

      Set CollectionView’s currentItem to null using FlexGrid’s CollectionView property since any data source is bind to FlexGrid, it creates CollectionView internally.
    2. If bind to CollectionView:

      Set CollectionView’s currentItem property to null.

    We are also surprised why default selection is null in your project. We are unable to replicate issue at our end with build 5.20163.254 too.

    Please refer to the attached sample for the same that is used to replicate issue at our end with build 5.20163.254.

    If you can share a sample depicting your issue, we will debug and let you know the reason for the same.

    Sorry again for inconvenience !

    Thanks,

    Manish Kumar Gupta

    2017/04/Wijmo_FlexGrid_defaultSelection_254.zip

  • Posted 14 September 2017, 12:01 pm EST

    Generally my code is quite simple and key parts are visible in the 1st post. I’m surprised that selection by default is… the default behaviour. So while I’m quite lucky that passing CollectionView makes FlexGrid NOT select any cell by default in my case (which seems to be a bug from your point of view), I’ll probably introduce this part with setting currentItem to null to make sure, no selection will stay when Wijmo will be updated in the future.

  • Posted 14 September 2017, 12:01 pm EST

    Hello,

    Thanks for your reply.

    We are sorry, you are still facing problem at your end.

    Since we are unable to replicate issue at our end , we cannot escalate this issue to the concerned team for further investigation.

    In the future if you are able to create a sample depicting your issue, we would be glad to help you.

    Thanks,

    Manish Kumar Gupta

  • Posted 14 September 2017, 12:01 pm EST

    But as I wrote, for me the problem is at your end and works good on my end (when using CollectionView - not simple array).

    Anyway, I’ve added

    grid.collectionView.currentItem = null
    per your suggestions so the case is closed. Would be good to add this info to the documentation next to
    selectionMode
    so users are aware how to control that part.

    Thanks for your help.

  • Posted 28 September 2018, 1:37 pm EST

    public flexGridInitialized(flexGrid: wjcGrid.FlexGrid) {

    flexGrid.collectionView.moveCurrentToPosition(-1);

    }

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels