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

Button Column Binding Errors

Sort Posts: Previous Next
  •  06-13-2008, 2:34 PM Post no. 12952

    Button Column Binding Errors

    HI

    I'm binding a column to a button template for the purposes of a delete cell button.

    I noticed in the debug window that the grid is actually trying to bind to the FieldName I have specified, and when it cannot find the field it is outputting allot of errors to the debug window.

    Of course the field does not really exist since it's for the button.

    Is there some way to tell the grid not to try and bind to the fieldname of the button column? I'm also thinking that this could cause performance issues.

     Thanks
     

  •  06-14-2008, 8:13 AM Post no. 12965 in reply to 12952

    Re: Button Column Binding Errors

    I am not sure I understand your question... Are you providing a button as the CellContentTemplate as demonstrated in the "Providing a data-cell template" example? If you want to change the binding, then you can set the column's DisplayMemberBinding property; however, this may not be the ideal situation depending on what you are trying to do. Would it be possible for you to post the XAML for the button template and where you are setting it?

     


    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  06-14-2008, 11:00 AM Post no. 12970 in reply to 12965

    Re: Button Column Binding Errors

    Hi Jenny. Yes I'm providing my own CellContentTemplate which looks something like this

    <DataTemplate x:Key="tmpButton">
                            <Button  ToolTip="View Product Asset Distribution"
                                    Width="16" Height="16" Template="{StaticResource myButton}">
                            </Button>
    </DataTemplate>

     

      <xcdg:Column FieldName="DeleteProduct"
                                 Title="Delete"
                                 CellContentTemplate="{StaticResource tmpButton}"
                                 MaxWidth="42"
                                 MinWidth="42"
                                 />


    Everything is working fine. I'm just seeing lots of binding errors in the debug output window because,obviously, the objects the grid is binding to does not have a field with the name DeleteProduct. So I'm just wondering if there is some way to tell the column not to try and bind to the nonexisting DeleteProduct field, since its being used as a button and not a column to display object data.

     
    Thanks
     

  •  06-16-2008, 7:24 AM Post no. 12983 in reply to 12970

    Re: Button Column Binding Errors

    Hi,

    Ideally it should not give you errors just because the fieldname you specified for the column does not exist in the data source.
    I've verified the same here by specifying a column with non-existent fieldname and it shows up without any error, just the cells in the column are blank. (I am binding my grid to a DataTable)

    In your case what I suggest is, to use one of the following two approaches;

    1. Either don't specify FiledName value at all. This way you will get a column without any data. This should work fine in the first place. If it not, then go for next solution.
    2. Since you are using the "Delete" column to place a delete button to delete a product that corresponds to the current row, you can bind that column to any other existing filed say "Product_ID". It is possible to bind multiple columns to a single field.
      Further, its upto you whether you want to use this value (say pass it to the .Tag proeprty of the Button in the template, so that it can be retrieved by the Click event handler of the button in order to know which product needs to be deleted) or just discard this value.
      The example xaml follows;

      <!-- Data Template -->
      < DataTemplate x : Key ="tmpButton">
          
      < Button  
                
      ToolTip ="View Product Asset Distribution"
                
      Width ="16"  
                
      Height ="16"  
               
      Template ="{StaticResource myButton }"
                
      Tag="{xcdg : CellEditorBinding }"
          
      />
      </ DataTemplate >

      <!-- Column with modified Fieldname -->
      <xcdg :Column  
                
      FieldName="Product_ID"  
                
      Title ="Delete"
                
      CellContentTemplate="{StaticResource tmpButton}"
                
      MaxWidth="42"
                
      MinWidth="42"
      />

    Hope it will suffice your need.


    Abdullah Ansari
    Senior Software Engineer
    OutworX Solutions Private Limited

    Everything is okay in the end. If its not okay, then its not the end.
  •  06-16-2008, 9:35 AM Post no. 12991 in reply to 12983

    Re: Button Column Binding Errors

    Hi abdullah

    Thanks for your input. 

    The first thing I tried was to not specify  a FieldName or to completely leave the FieldName property blank.

    In both cases the grid throws a XamlParseException.

    So for now I'm binding to a field that exists, even though I'm not using it.

    Maybe X-Ceed could look into this? 

    Thanks
     

  •  06-16-2008, 11:51 AM Post no. 12997 in reply to 12991

    Re: Button Column Binding Errors

    FieldName property is mandatory, it cannot be left out.

    However, you can clear the binding error by making sure the FieldName maps to something that resolves without error. My suggestion is to use "." so that the binding will resolve to the whole data item ( which should not cause you any problems if your column is not editable ).

    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  08-10-2011, 2:17 PM Post no. 30857 in reply to 12997

    Re: Button Column Binding Errors

    What happens when you have more than one such column? Duplicate field names are also forbidden.

     

    Basically, my problem is that I have a series of templated blank "spacer" columns throughout my grid, but it's throwing up a ton of binding errors because the column title "spacer1" doesn't correspond to anything in the object model of what the grid is bound to. How can I set up those columns so that they aren't looking for any kind of binding.

     Example:

    
    

     <xcdg:Column VisiblePosition="0" FieldName="BurnCost" Title="Burn Cost"  CellEditor="{StaticResource ...}" CellContentTemplate="{StaticResource ...}" />
     <xcdg:Column VisiblePosition="0" FieldName="LossFit" Title="Loss Fit" CellEditor="{StaticResource ...}" CellContentTemplate="{StaticResource ...}" />
    <!-- Spacer -->
    <xcdg:Column VisiblePosition="0" FieldName="Spacer1" MaxWidth="2" MinWidth="2" ShowInColumnChooser="False" Title="" CellContentTemplate="{StaticResource GridSpacerDark}" ReadOnly="True" />

     <xcdg:Column VisiblePosition="0" Width="100" FieldName="Weight" Title="Weight"...  />
     <xcdg:Column VisiblePosition="0" Width="100" FieldName="Something" Title="Something"...  />
      <!-- Spacer -->
      <xcdg:Column VisiblePosition="0" FieldName="Spacer2" MaxWidth="2" MinWidth="2" ShowInColumnChooser="False" Title="" CellContentTemplate="{StaticResource GridSpacerDark}" ReadOnly="True" />

      <xcdg:Column VisiblePosition="0" FieldName="Modeled" Title="Modeled"...  />

     

             <!-- Used for spacer columns -->
            <DataTemplate x:Key="GridSpacerDark">
                <TextBlock Margin="-3,-2,-1,-2" Foreground="LightGray" Background="LightGray" Text="" />
            </DataTemplate>

     


    Alain
  •  08-16-2011, 11:05 AM Post no. 30876 in reply to 30857

    Re: Button Column Binding Errors

    Hi Alain,

    If you are looking to use Columns to space out the DataGrid, you can use UnboundColumns. The FieldName that you provide will not be displayed in the ColumnManagerRow. For example:

    XAML

    --------------------

     <xcdg:DataGridControl Name="MyDGC" AutoCreateColumns="True" ItemScrollingBehavior="Immediate" Grid.Row="1"
                              ReadOnly="False" ItemsSource="{Binding Source={StaticResource dgcvs}}"
                                  SelectionMode="Extended"  SelectionUnit="Cell"
                                  UpdateSourceTrigger="CellContentChanged"
                                  >
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="Column1" Title="Column1" />
                    <xcdg:Column FieldName="Column2" Title="Column2" />
                    <xcdg:UnboundColumn FieldName="Space1" Title="" Width="2" MaxWidth="30" MinWidth="30" ShowInColumnChooser="False" />
                    <xcdg:Column FieldName="Status"
                                 Title="Status"
                                 CellEditorDisplayConditions="MouseOverCell">
                    </xcdg:Column>
                    <xcdg:Column FieldName="Column4" Title="Column4" />
                    <xcdg:UnboundColumn FieldName="Space2" Title="" Width="2" MaxWidth="150" MinWidth="150" ShowInColumnChooser="False" />
                    <xcdg:Column FieldName="Column5" Title="Column5" />
                    <xcdg:Column FieldName="Column6"
                                 Title="Column6"
                                 CellContentTemplate="{StaticResource BusinessObjectType}"
                                 AllowAutoFilter="True"  />
                </xcdg:DataGridControl.Columns>
            </xcdg:DataGridControl>

    --------------------


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
  •  10-05-2011, 9:04 AM Post no. 31154 in reply to 30876

    Re: Button Column Binding Errors

    Using UnboundColumn solved it, thanks.

    Alain
  •  10-11-2011, 3:45 PM Post no. 31192 in reply to 30876

    Re: Button Column Binding Errors

    Actually, as it turns out, switching them to UnboundColumn makes all columns unresizable. As soon as you try to resize any column, including normal ones, an exception is thrown. Give it a shot. When I turn unboundcolumns back into regular columns, this error goes away.

    So I cannot use unbound columns and the problem remains :/


    Alain
  •  10-12-2011, 7:23 AM Post no. 31195 in reply to 31192

    Re: Button Column Binding Errors

    Hi Alain,

    Are you able to attach a sample application that shows this behavior? I am not getting these errors on my end. What exact version of the DataGrid are you using? The current version of the Xceed DataGrid for WPF is 4.2.11480.14340 for .NET framework 4.0. Please include the DataGrid DLLs necessary to make your sample application run.

    You can send your application by email at support@xceed.com or you can attach it to the forum by clicking on the 'Options' tab when you reply.

    With this information, I can provide you with a possible solution to the issues you are currently experiencing. I have also attached a sample application which is written in .NET framework 4.0 that does not show any of the errors. Let me know if there is any other information that I need to help you with.


    Marc

    Developer in Technical Support
    Xceed - Multi-talented components - http://xceed.com
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.