1

So I am binding a data-table to my grid where I have some columns but based on two columns I need to compute a formatted value like in the below example, I want to display a FullName = fname + " " + lname using a converter. My below XAML isn't working. Offcourse I want to do something a little mre complex that just adding strings in my converter.

                    <syncfusion:GridUnBoundColumn.ValueBinding>
                        <MultiBinding Converter="{StaticResource FullNameFormatingConverter}">
                            <MultiBinding.Bindings>
                                <Binding Path="fname" />
                                <Binding Path="lname" />
                            </MultiBinding.Bindings>
                        </MultiBinding>
                    </syncfusion:GridUnBoundColumn.ValueBinding>

How can I achieve the suggested binding in my grid?

user11594
  • 13
  • 3
  • I am not familiar with `GridUnBoundColumn`, however you may need to set the DataContext of your bindings to your grid – Jack Mar 22 '18 at 10:24
  • The DataContext is all set properly, other columns do show up properly. The issue I am facing is how to supply two mapping names to a MultiValue Converter – user11594 Mar 22 '18 at 10:29
  • The application builds, everything else is fine but my converter doesnt work! Even though fname and lname are columns inside the datatable which the grid is bound too, this column jsut shows a System.DataRow... text.. say I have 3 rows and the first row has fname = Jack and lname = Sparrow, I want this column to show "Jack Sparrow". I jsut need to know the syntax to supply these column values to the converter properly. – user11594 Mar 22 '18 at 10:50
  • Have you considered using a StringFormat in the MultiBinding, as illustrated [here](https://stackoverflow.com/q/8377471/109702)? – slugster Mar 22 '18 at 11:22
  • In the above case it doesnt break at y converter code. – user11594 Mar 22 '18 at 11:52
  • Thank you all for your help! Really appreciate it! – user11594 Mar 22 '18 at 12:35

1 Answers1

0

Did you try to use the Format property?

<syncfusion:GridUnBoundColumn Format="'{fname} {lname}'" />

Or a GridTemplateColumn with a CellTemplate:

<syncfusion:GridTemplateColumn.CellTemplate>
    <DataTemplate>
        <TextBlock>
            <TextBlock.Text>
                <MultiBinding Converter="{StaticResource FullNameFormatingConverter}">
                    <MultiBinding.Bindings>
                        <Binding Path="fname" />
                        <Binding Path="lname" />
                    </MultiBinding.Bindings>
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    </DataTemplate>
</syncfusion:GridTemplateColumn.CellTemplate>
mm8
  • 163,881
  • 10
  • 57
  • 88
  • Thanks this works like a charm! Looks like the issue was using an syncfusion:GridUnBoundColumn, for some reasn it was never identifying the column mappings. The other columns work! Even the CellTemplate works! – user11594 Mar 22 '18 at 12:16