1 Reply Latest reply on Jul 20, 2007 11:35 AM by Mitek17

    programaticaly select dataGrid Item

    levancho Level 3
      i am trying to set datagrid selectedItem programaticlly , I also want it to visually display my programatically selected item and show that it is highlighted, same ways as if it was clicked by mouse.

      i tried this :
      nl2.selectedItem = item;
      and then nl2.validateNow();

      it seems to be setting that as value of selectedItem attribute of that datagrid but it does not show visually meaning : datagrid does not highlight that selected item,
      I know there is something I am missing but cant seems to be finding the asnwer and aunt google did not know that either
        • 1. programaticaly select dataGrid Item
          Mitek17 Level 1
          Hi levancho,

          I believe that there is a bug in Flex2 SDK -with selectedItem/selectedIndex properties.

          If you assign selectedItem - it does not work all the times.
          If you assign selectedIndex a number - it works OK, item will be selected in the grid. I am not sure about selectedItem behaviour in this case, but it is definitely not null.

          Also there is also another a bug, if you say selectedIndex = -1 it won't set selectedItem to null. I.e. selection will disappear, but selectedItem != null;

          And you should be sure that when you do the assignment to selectedItem the value should be from the dataProvider.

          Cheers,
          Dmitri.