Welcome to the Xceed Community | Help
Community Search  
More Search Options

DataGridUnboundItemProperty only gives EmptyDataItem when querying for value

Sort Posts: Previous Next
  •  01-10-2010, 1:15 PM Post no. 25380

    DataGridUnboundItemProperty only gives EmptyDataItem when querying for value

    Once I got past my silly mistakes and was able to get a DataGridUnboundItemProperty to hit my event handler for QueryValue, I found that I only ever receive an EmptyDataItem as e.Item, instead of a DataRowView as all the examples I have found indicate.  Of course, I can't calulate much with only an EmptyDataItem.  The first column shows up fine, I just can't get to the data to calculate the second.

    Any help in pointing me in the right direction would be greatly appreciated.

    In case it matters, I'm using the TableFlowView.

    Below is the declaration of the DataGridCollectionViewSource:

    <xcdg:DataGridCollectionViewSource x:Key="cvsInvoices" Source="{Binding ElementName=root, Path=Invoices}" AutoCreateItemProperties="False">

      <xcdg:DataGridCollectionViewSource.ItemProperties>

        <xcdg:DataGridItemProperty Name="Invoice_Number" Title="Invoice Num"/>

        <xcdg:DataGridUnboundItemProperty Name="Total_Cost" Title="Cost" DataType="sys:String" QueryValue="OnQueryValueTotalCost"/>

      </xcdg:DataGridCollectionViewSource.ItemProperties>

    </xcdg:DataGridCollectionViewSource>

    And the definition of the QueryValue event handler:

    private void OnQueryValueTotalCost( object sender, DataGridItemPropertyQueryValueEventArgs e )

    {

      var _row = e.Item as DataRowView;

      if( _row == null || _row["Invoice_ID"] == DBNull.Value )

        e.Value = string.Empty;

      else

      {

        int _iInvId = (int)_row["Invoice_ID"];

      }

    }

  •  01-11-2010, 8:20 AM Post no. 25390 in reply to 25380

    Re: DataGridUnboundItemProperty only gives EmptyDataItem when querying for value

    OK, so I've taken it a step further and have been able to answer two of my own questions:

    - the examples use a DataRowView because it is binding the DataGridControl to a DataSet

    - the EmptyDataItem given in the QueryValue handler IS in fact because I was using TableflowView.  When I change it to TableView, I get the item that I have bound to the grid.

     So I guess that tightens up my question to, how do I use calculated, unbound columns with TableflowView?  I have seen in other threads that the EmptyDataItem is used for performance reasons initially, but then I would expect the real value to be queried for with the row being displayed.

    Any thoughts?

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.