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.
Unfortunately, activation email could not send to your email. Please try again.

Stacking data in columns

Thread ID:

Created:

Updated:

Platform:

Replies:

124064 May 12,2016 10:54 AM May 12,2016 11:36 PM UWP 3
loading
Tags: SfDataGrid
Garling Beard
Asked On May 12, 2016 10:54 AM

Currently I have my datagrid pulling and assigning data to each columns separately. Lets say I have 4 columns, I want to be able to have the data in column 1 equal column 1 and column 2 stacked. 

MainPage.xmal
<Page.DataContext>
        <local:vmCustomers />
</Page.DataContext>

<Grid:SfDataGrid x:Name="dgCustomers"
                           AutoGenerateColumns="False"
                           ScrollViewer.HorizontalScrollMode="Auto" 
                           ScrollViewer.VerticalScrollMode="Auto"
                           NavigationMode="Row"
                           ItemsSource="{Binding Customers}" Margin="0,137,0,0">
            <Grid:SfDataGrid.Columns>
                <Grid:GridTextColumn ColumnSizer="SizeToHeader" HeaderText="Customer Number" MappingName="custNumber" />
                <Grid:GridTextColumn ColumnSizer="SizeToCells" TextWrapping="NoWrap" HeaderText="Customer Name" MappingName="custName" />
                <Grid:GridTextColumn ColumnSizer="SizeToCells" TextWrapping="NoWrap" HeaderText="Address" MappingName="custAdd1" />
                <Grid:GridTextColumn ColumnSizer="SizeToCells" TextWrapping="NoWrap" HeaderText="Address 1" MappingName="custAdd2" />                
            </Grid:SfDataGrid.Columns>
</Grid:SfDataGrid>

vmCustomers.cs

public class vmCustomers
    {
        private ObservableCollection<dmCust> _customers;
        public ObservableCollection<dmCust> Customers
        {
            get { return _customers; }
            set { _customers = value; }
        }

        public string TMNumber { get; private set; }

        public vmCustomers()
        {            
            _customers = new ObservableCollection<dmCust>();
            this.GenerateOrders();
        }

        
        private async void GenerateOrders()
        {
            
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "cust.db");

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                
                var custQry = from p in conn.Table<cust>()
                              where p.CMRP1 == DataClass.tmNumber
                              select new
                              {
                                  CustomerID = p.ID,
                                  CustomerNumber = p.CMCSNO,
                                  CustomerName = p.CMCSNM,
                                  CustomerAddress = p.CMCAD1,
                                  CustomerAddress2 = p.CMCAD2,
                                  
                              };
                try
                {
                    foreach (var d in custQry)
                    {
                        _customers.Add(new dmCust(d.CustomerID, d.CustomerNumber, d.CustomerName, d.CustomerAddress, d.CustomerAddress2, ));
                        int cnt = 0;
                        cnt++;
                        System.Diagnostics.Debug.WriteLine(cnt);                        
                    }
                    
                }
                catch
                {
                    var dialog = new MessageDialog("You must perform a database sync");
                    await dialog.ShowAsync();
                }


            }
            
        }

       
    }

Sivakumar R [Syncfusion]
Replied On May 12, 2016 12:04 PM

Hi Garling, 
 
Your requirement can be achieved using GridTemplateColumn or GridColumn.CellTemplate. Please find the UG link for the same, 
 
You can change the row height also if needed. Please find the documentation link below, 
 
Please let us know if you have any queries. 
 
Thanks, 
Sivakumar 


Garling Beard
Replied On May 12, 2016 03:31 PM

Thank you, that was what I needed. 

Srinivasan Vasu [Syncfusion]
Replied On May 12, 2016 11:36 PM

Hi Garling, 
  
Thanks for your update. 
  
Regards, 
Srinivasan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;