Hi all togehter,
i have multiline Text in my dataGrid Rows. The customization is done by 'DataGrid_QueryRowHeight'.
This is the XAML for the MultiLine Column:
<!-- Description -->
<Syncfusion:GridTemplateColumn HeaderText="Beschreibung" Width="200"
TextWrapping="Wrap"
CellStyle="{StaticResource GridTextColumnStyle}"
MappingName="Description">
<Syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Description}"
Style="{StaticResource TextBlockStyleF16}"
TextWrapping="Wrap" />
</DataTemplate>
</Syncfusion:GridTemplateColumn.CellTemplate>
<Syncfusion:GridTemplateColumn.EditTemplate>
<DataTemplate>
<TextBox Text="{Binding Description, Mode=TwoWay}"
Style="{StaticResource TextBoxStyleF16}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Syncfusion:FocusManagerHelper.FocusedElement="True"
AcceptsReturn="True"
TextWrapping="Wrap" />
</DataTemplate>
</Syncfusion:GridTemplateColumn.EditTemplate>
</Syncfusion:GridTemplateColumn>
a) is there an chance to adjust the Rowheight during edit the Column.
b) How ca i adjust the AddNew-Row to a resonable height, a the moment when i use Addnew, the <row is very very small.
Thanks
Peter
private void DataGrid_QueryRowHeight(object sender, Syncfusion.UI.Xaml.Grid.QueryRowHeightEventArgs e)
{
if(this.dataGrid.IsAddNewIndex(e.RowIndex))
{
e.Height = 40;
e.Handled = true;
} |
this.dataGrid.QueryRowHeight += dataGrid_QueryRowHeight;
this.dataGrid.CurrentCellEndEdit += dataGrid_CurrentCellEndEdit;
void dataGrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs args) {
dataGrid.InvalidateRowHeight(args.RowColumnIndex.RowIndex);
dataGrid.GetVisualContainer().InvalidateMeasureInfo();
}
void dataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e)
{ if (this.dataGrid.GridColumnSizer.GetAutoRowHeight(e.RowIndex, gridRowResizingOptions, out autoHeight))
{
if (autoHeight > 24) { e.Height = autoHeight; e.Handled = true;
} } } |
Hi,
sorry for my bad Explanation.
What i would like to do:
Goto the 'AddNewRow' and click -> new Row in Grid
Open a Dialog to select a OrderItem
Select a OrderItem in the Dialog.
Add the selected Item to the newly added Row.
This is what the 'OnMaterialNavigationChanged' function is doing in the ViewModel
This works fine with MSDataGrid and MVVM, so i think this should work in SfDataGrid as well.
Thanks
Peter
private void DataGrid_AddNewRowInitiating(object sender, AddNewRowInitiatingEventArgs e)
{
//Here we have show the combo box in the secondary window. and select the value from the window
Window window = new Window();
window.Title = "Please select a item from combo box";
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
window.Height = 100;
window.Width = 250;
StackPanel sp = new StackPanel();
sp.Orientation = Orientation.Horizontal;
sp.VerticalAlignment = System.Windows.VerticalAlignment.Center;
sp.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
sp.Width = 200;
sp.Height = 100;
ComboBox cmb = new ComboBox();
cmb.ItemsSource = new ViewModel().Orders;
cmb.SelectionChanged += Cmb_SelectionChanged;
cmb.Width = 100;
cmb.Width = 50;
Button bb = new Button();
bb.Content = "Ok";
bb.Click += Bb_Click;
bb.Height = 30;
bb.Margin = new Thickness(20, 0, 0, 0);
sp.Children.Add(cmb);
sp.Children.Add(bb);
window.Content = sp;
window.ShowDialog();
//Here we have make that record as the added record content.
var data = e.NewObject as OrderInfo;
if (record == null)
return;
data.OrderID = ((_130032.OrderInfo)record).OrderID;
data.CustomerID = ((_130032.OrderInfo)record).CustomerID;
data.CustomerName = ((_130032.OrderInfo)record).CustomerName;
data.ShipCity = ((_130032.OrderInfo)record).ShipCity;
data.Country = ((_130032.OrderInfo)record).Country;
if (_view.SelectedItem==null)
{
_view.SelectedItem = data;
}
record = null;
} |
Hi,
yes, i need further asistance.
Your example brings me only the half way.
Please have a look to my writing from yesterday, 02:18 pm (LeftPane - RightPane)
Thanks
Peter
private async void DataGrid_AddNewRowInitiating(object sender, Syncfusion.UI.Xaml.Grid.AddNewRowInitiatingEventArgs e)
{
//Provide the focus to combo box maintained in the left pane of the screen
await System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
{
cmb.Focus();
cmb.IsDropDownOpen = true;
}), DispatcherPriority.ApplicationIdle);
do
{
await Task.Delay(500);
} while (!isSelected);
var data = e.NewObject as OrderInfo;
if (record == null)
return;
data.OrderID = ((WpfApplication1.OrderInfo)record).OrderID;
data.CustomerID = ((WpfApplication1.OrderInfo)record).CustomerID;
data.CustomerName = ((WpfApplication1.OrderInfo)record).CustomerName;
data.ShipCity = ((WpfApplication1.OrderInfo)record).ShipCity;
data.Country = ((WpfApplication1.OrderInfo)record).Country;
record = null;
isSelected = false;
}
}
|