Home Forums WPF controls Xceed DataGrid for WPF Grid Data Not Displayed from DataSet

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26559 |

    This is my very first grid. I am using the basic dataset/binding example but no data is being displayed on my WPF form. The app has a registered license.

    Assumptions: Code returns a dataset which is populated with data from our backend. Dataset is a valid object with data. Columns are defined and limited to those displayed. I also tried the NW Orders table with no luck. It’s not the presence or lack of data.

    Also: What does x:Key mean? Is that really the db table key? Ok, I tried that too with no luck. I might as well put my dogs name there, I don’t think it matters as long as it matches the StaticResource.

    Ideas? Thanks in advance.

    xaml:
    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvs_records”
    Source=”{Binding Source={x:Static Application.Current},
    Path=Records}”/>
    </Grid.Resources>
    <xcdg:DataGridControl x:Name=”OrdersGrid”
    ItemsSource=”{Binding Source={StaticResource cvs_records}}”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”transcontractid” Title=”Transcontractid” />
    <xcdg:Column FieldName=”transenergytypeid” Title=”Transenergytypeid” />
    <xcdg:Column FieldName=”effectivedate” Title=”Effectivedate” />
    <xcdg:Column FieldName=”terminationdate” Title=”Terminationdate” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
    </Grid>

    Code Behind:

    public void btnGetData_Click(object sender, RoutedEventArgs e)
    {
    try
    {
    ChannelFactory<IMOIService> fact =
    new ChannelFactory<IMOIService>(“cmanager”);
    IMOIService mgr = fact.CreateChannel();

    if (fact == null)
    {
    Console.WriteLine(“Unable to obtain a Reference to Server…”);
    return;
    }

    // Calls my get data method, records are returned
    DataSet ds = mgr.GetSomeData();
    // Ok, set the property even though it doesn’t do a damn thing
    m_records = ds.Tables[0];

    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    }
    }

    public static DataTable Records
    {
    get
    {
    return m_records;
    }
    }

    private static DataTable m_records;

    Imported from legacy forums. Posted by dontgoeasy (had 5266 views)

    Xceed Support
    Member
    Post count: 5658

    Your property is most likely located in the MainWindow rather than in the App code-behind file. That said, change the binding of the DataGridCollectionViewSource’s Source property to a RelativeSource binding and you should be fine.

    {Binding RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow}}, Path=Records}

    As for x:Key <a href=”http://msdn2.microsoft.com/en-us/library/ms742804.aspx”>http://msdn2.microsoft.com/en-us/library/ms742804.aspx</a&gt;

    Imported from legacy forums. Posted by Jenny [Xceed] (had 209 views)

    User (Old forums)
    Member
    Post count: 23064

    Jenny,
    I gather Binding RelativeSource={RelativeSource AncestorType={x:Type local:MainWindow} is a WPF construct but where does the MainWindow reference from? I keep getting “can’t find type MainWindow”

    Thanks

    Imported from legacy forums. Posted by dontgoeasy (had 497 views)

    User (Old forums)
    Member
    Post count: 23064

    Just a note:

    After setting my ItemSource value, I see my grid now has a positive value of items. The problem is I cannot see them.

    OrdersGrid.ItemsSource = mDataRows;
    int jcount = OrdersGrid.Items.Count;

    I have set the view respectively to the workspace and the class..

    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvs_records” Source=”{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MyClient}},
    Path=Records}”/>
    </Grid.Resources>

    Where MyClient is the main window class.

    Imported from legacy forums. Posted by dontgoeasy (had 337 views)

    Xceed Support
    Member
    Post count: 5658

    The ItemsSource property should be set to the DataGridCollectionViewSource:

    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvs_records” Source=”{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MyClient}},
    Path=Records}”/>

    <xcdg:DataGridControl x:Name=”OrdersGrid”
    ItemsSource=”{Binding Source={StaticResource cvs_records}}”/>

    </Grid.Resources>

    Imported from legacy forums. Posted by Jenny [Xceed] (had 209 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Jenny,
    Ok, yes LOL on the current setting. When set as below and without providing a code behind ItemsSource, I don’t even get the grid lines. If I add the code behind item, I get gridlines but no data. At least I can see a row count. How can the grid contain rows, but those rows be invisible?

    So setting OrdersGrid.ItemsSource = mDataRows;
    int jcount = OrdersGrid.Items.Count;

    Give the grid a row count, but they are invisible?

    <Grid xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <Grid.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”cvs_records” Source=”{Binding RelativeSource={RelativeSource AncestorType={x:Type local:MyClient}},
    Path=Records}”/>
    </Grid.Resources>
    <xcdg:DataGridControl x:Name=”OrdersGrid”
    ItemsSource=”{Binding Source={StaticResource cvs_records}}”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”ROWNUM” Title=”rownumber” />
    <xcdg:Column FieldName=”transcontractid” Title=”Transcontractid” />
    <xcdg:Column FieldName=”transenergytypeid” Title=”Transenergytypeid” />
    <xcdg:Column FieldName=”effectivedate” Title=”Effectivedate” />
    <xcdg:Column FieldName=”terminationdate” Title=”Terminationdate” />
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
    </Grid>

    Imported from legacy forums. Posted by dontgoeasy (had 498 views)

    User (Old forums)
    Member
    Post count: 23064

    After experimenting with Xceed for a few days, I’ve come to the realization, that that product is still very much in its infancy and does not yet support backline Oracle datasets or for that matter SQL Server objects. Apparently it does well with MS Access (their only model), but this product will never be ready for our production schedule.

    I discovered a work around for using the infamous and still very capable Windows grid under the WPF platform. Below is a link which will have your very capable Windows grid up in about 10 minutes.

    http://geekswithblogs.net/lorint/archive/2006/09/09/90740.aspx

    Imported from legacy forums. Posted by dontgoeasy (had 575 views)

    Xceed Support
    Member
    Post count: 5658

    Hi dontgoeasy,

    After reviewing the complete thread, a question emerges.

    Is the code submitted initially still right? I mean is the Records property still “populated” only after a button click from the UI ?

    I do ask the question because I noticed that the Records property is not a DependencyProperty and does not implement explicit change notification neither (INotifyPropertyChanged).

    This could explain why the data grid does not display any data since the framework does not get notified that the binding to the Records property need to be updated and therefore that the data grid has no data to show.

    Also, I regret that you feel that the DataGrid for WPF is not a mature product, and if you are willing to share your particular concerns, then we can see if these are addressable and that for those of these points that are not acceptably handled by the product, we can create feature requests so they can make it in the product.

    As can be seen from the history of features and updates for the product, we have been extremely serious about providing the most comprehensive feature set, largest possible support for data sources and have been listening to our users feedback ever since the initial release. So do not hesitate to voice your concerns.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 5506 views)

    User (Old forums)
    Member
    Post count: 23064

    I agree.  I’ve followed this post and I definitly can’t get the columns to show up.

     I am experiencing the same issue… Here is the simplest of grids definitions:

    <xcdg:DataGridControl Name=”ODBCTest_DataGrid” ItemScrollingBehavior=”Immediate” ReadOnly=”True”>

    </xcdg:DataGridControl>

    And here is the code behind for populating it:

    ODBCPoller_DataGrid.ItemsSource = DAL.FillTable(selectedItem.SelectSQL).DefaultView;

    Note: The FillTable returns a DataTable:

    What I get is a scrollbar sized to the correct number of rows, but no data for the columns…

    How come it doesn’t autogenerate the columns?

    Imported from legacy forums. Posted by mrbradleyt (had 853 views)

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.