We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Setting selected node

Hello,

In my application I have 2 GridTree controls. When the application launches it reads some data and depending on that populates the first grid and based on the selected value the second one's contents are loaded. 

Is it possible to set the selected row of a grid programmatically on start? I set SelectedNode value but the row doesn't appear to be selected.

Thanks.

3 Replies

SP Sowndaiyan Paulpandi Syncfusion Team December 22, 2015 10:54 AM UTC

Hi Volkan,


Thank you for contacting Syncfusion Support.


We have analyzed your query. You can achieve your requirement “set the selected row of a grid programmatically on initially” like the below code example. In this code example, we have added the corresponding node to TreeGrid.InternalGrid.SelectedNodes and the IsSelected property of the particular node is set to true.


Code Example [C#]:



public
MainWindow()

        {

            InitializeComponent();

            this.treeGrid.Loaded += treeGrid_Loaded;

        }


void treeGrid_Loaded(object sender, RoutedEventArgs e)

        {

            var Node = treeGrid.InternalGrid.Nodes.FirstOrDefault(node => (node.Item as EmployeeInfo).EmpID == 1005);

            if (Node == null)

                return;

            Node.IsSelected = true;

            treeGrid.InternalGrid.SelectedNodes.Add(Node);

        }


We have prepared a sample as per your requirement and you can download sample from the below location,

Sample : http://www.syncfusion.com/downloads/support/forum/121500/ze/Tree_node_selection_with_specific_row831819400



Regards,

Sowndaiyan





VP Volkan Paksoy December 22, 2015 11:03 AM UTC

Worked beautifully! Thank you very much for the help.


SP Sowndaiyan Paulpandi Syncfusion Team December 23, 2015 04:44 AM UTC

Hi Volkan,


Thanks for the update.


Please let us know if you need further assistance.


Regards,

Sowndaiyan

Loader.
Live Chat Icon For mobile
Up arrow icon