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

how to bind GridDataVisibleColumn from ObservableCollection programmatically?

Hi,
          Could you tell me how to bind GridDataVisibleColumn from ObservableCollection<ColumnChooserItems> programmatically without using binding property in design view?

Thank you.

1 Reply

SM Saravanan M Syncfusion Team November 18, 2014 09:22 AM UTC

Hi Shwe,

 

Thank you for Contacting Syncfusion support,

 

We have analyzed your query. You can bind the GridDataVisiblecolumn in code behind instead of binding in XAML from ObservableCollection. Please refer the below code snippet.

 

Code Snippet[C#]:

ObservableCollection<GridDataVisibleColumn> _Columns;

ObservableCollection<GridDataVisibleColumn> Columns

{

            get { return _Columns; }

            set { _Columns = value; }

}

public ObservableCollection<GridDataVisibleColumn> GetColumns()

{

  var columns = new ObservableCollection<GridDataVisibleColumn>();

  columns.Add(new GridDataVisibleColumn() {MappingName="CustomerID" });

   return columns;

}

 

public MainWindow()

{

  InitializeComponent();

  Columns = GetColumns();

  syncgrid.VisibleColumns.Add(Columns[0]);

  syncgrid.VisibleColumns.Add(Columns[1])

}

 

We have prepared a sample based on this and you can download it form below location,

 

Sample Location: GridDataControl_Sample.zip

 

We have a SfDataGrid control like GridDataControl. But compare to GridDataControl, SfDataGrid having a better performance and flexibility. SfDataGrid assists you to create entirely customizable and highly interactive features used to display and manipulate the huge amount of data. So, we suggest you to use SfDataGrid instead of GridDataControl.

 

We have prepared a sample based on the same scenario in SfDataGrid and you can download it from below location.

 

Sample Location: SampleApplication.zip

 

Please let us know if you have any queries,

 

Regards,

Saravanan.M

 


Loader.
Up arrow icon