<i:Interaction.Triggers>
<i:EventTrigger EventName="RowValidated">
<i:InvokeCommandAction Command="{Binding Path=RowValidated}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
private ICommand _rowValidated;
public ICommand RowValidated
{
get
{
return _rowValidated ?? (_rowValidated = new RelayCommand(CanExecute));
}
}
private bool _canExecute;
public void CanExecute(object obj)
{
} |
<Syncfusion:SfDataGrid x:Name="datagrid"
AllowEditing="True"
SelectionUnit="Cell"
AutoGenerateColumns="False"
AllowFiltering="True"
ShowGroupDropArea="True"
ItemsSource="{Binding GDCSource}"
AllowSorting="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="RowValidated">
<i:InvokeCommandAction Command="{Binding Path=RowValidated}" CommandParameter="{Binding ElementName=datagrid, Path=CurrentItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Syncfusion:SfDataGrid> |
<Syncfusion:SfDataGrid ItemsSource="{Binding GDCSource}"
AllowSorting="True">
<Syncfusion:SfDataGrid.RecordContextMenu>
<ContextMenu Style="{x:Null}">
<MenuItem Command="{Binding DataGrid.DataContext.CMenuCommand}" Header="Header"/>
</ContextMenu>
</Syncfusion:SfDataGrid.RecordContextMenu>
</Syncfusion:SfDataGrid> |
because CMenuCommand is available at Window DataContext and not the DataGrid DataContext level.
Here is my XAML
<Syncfusion:SfDataGrid x:Name="datagrid"
AllowEditing="True"
SelectionUnit="Cell"
AllowFiltering="True"
AutoGenerateColumns="True"
ShowGroupDropArea="True"
ItemsSource="{Binding GDCSource}"
AllowSorting="True">
<Syncfusion:SfDataGrid.RecordContextMenu>
<ContextMenu Style="{x:Null}">
<MenuItem Command="{Binding DataGrid.DataContext.CMenuCommand}" Header="Header"/>
</ContextMenu>
</Syncfusion:SfDataGrid.RecordContextMenu>
<i:Interaction.Triggers>
<i:EventTrigger EventName="RowValidated">
<i:InvokeCommandAction Command="{Binding Path=RowValidated}" CommandParameter="{Binding ElementName=datagrid, Path=CurrentItem}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Syncfusion:SfDataGrid>
<Syncfusion:SfDataGrid x:Name="datagrid" >
<Syncfusion:SfDataGrid.RecordContextMenu>
<ContextMenu Style="{x:Null}">
<MenuItem Command="{Binding DataGrid.DataContext.CMenuCommand}" CommandParameter="{Binding}" Header="Header"/>
</ContextMenu>
</Syncfusion:SfDataGrid.RecordContextMenu>
</Syncfusion:SfDataGrid> |
<Syncfusion:SfDataGrid x:Name="datagrid" >
<Syncfusion:SfDataGrid.RecordContextMenu>
<ContextMenu Style="{x:Null}">
<MenuItem Command="{Binding DataGrid.DataContext.CMenuCommand}" CommandParameter="{Binding Path=DataGrid.CurrentItem}" Header="Header"/>
</ContextMenu>
</Syncfusion:SfDataGrid.RecordContextMenu>
</Syncfusion:SfDataGrid> |
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions> |
void sfdatagrid_Loaded(object sender, RoutedEventArgs e)
{
this.sfdatagrid.MaxHeight = this.Height;
} |
Hi,
I have run into one more issue of data not populating into sfDataGrid. I have a similar grid where data is being populated just fine.
Here is my View model property which contains OnservableCollection<Institution>
I conformed that it has few rows of data in it..
ViewModel Class property declaration
public ObservableCollection<Institution> InstitutionList { get; set; }
In my VieModel Constructor,
InstitutionList = new ObservableCollection<Institution>(institutionOperations.GetAllInstitutions());
Here is my very simple DataGrid xaml for my user control
<UserControl.DataContext>
<viewModels:AllInstitutionsViewModel />
</UserControl.DataContext>
<Syncfusion:SfDataGrid Grid.Row="1" ItemsSource="{Binding Path=InstitutionList, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" AutoGenerateColumns="False" x:Name="InvestorsGrid" HorizontalAlignment="Center" Margin="10,20,10,10" SelectionUnit="Row" AllowFiltering="True" ShowGroupDropArea="True" Style="{DynamicResource SfDataGridStyle1}">
<Syncfusion:SfDataGrid.Columns>
<Syncfusion:GridTextColumn MappingName="Name" HeaderText="Name" AllowSorting="True" HorizontalHeaderContentAlignment="Stretch"/>
</Syncfusion:SfDataGrid.Columns>
</Syncfusion:SfDataGrid>
When I run this, the grid is completely empty. It even doesn't have the column called "Name"
Can someone please point me what I am doing wrong here.
As I said, I have similar model which works perfectly fine.
Hi Andy,
By default in SfDataGrid the GridHyperLink column fired the link while clinking the cell at first time.
Sample:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/Gridhyperlinkcolumn-519990559.zip
Could you please check this in your side and if still the this occurs then please modify the sample replicate the issue. This would be more helpful fos us to provide the better solution.
Regards,
Jai Ganesh S
<Syncfusion:SfDataGrid AutoGenerateColumns="False" HorizontalAlignment="Left" Name="datagrid" AllowEditing="True" ItemsSource="{Binding model}" VerticalAlignment="Top" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="CurrentCellRequestNavigate">
<i:InvokeCommandAction Command="{Binding Path=CurrentCellRequestNavigateCommand}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Syncfusion:SfDataGrid>
private RelayCommand _editCommand;
public ICommand CurrentCellRequestNavigateCommand
{
get
{
if (_editCommand == null)
{
_editCommand = new RelayCommand(param => this.LoadUser(param));
}
return _editCommand;
}
}
public void LoadUser(object ob)
{
//Write your code here
} |