Hi,
I need to create a XamDataGrid with configurable columns. But the first column on the left should always be displayed on the left and never be moved from there.
- I need to disable the possibility to drag and drop this column.
- I need to prevent some other columns to be draged and droped on the left of this column.
does any body has suggestions?
Thanks
Hi Croesusdev,
As far I can see you are looking for a way to freeze specific (the firs column ) and the others can fixed and moved freely without taking the first position. Based on this requirements I have modified Elizabeth’s sample in order hold the first filed always on first position by changing the FieldPositionChanged and FieldPositionChanging:
private void xamDataGrid1_FieldPositionChanged(object sender, Infragistics.Windows.DataPresenter.Events.FieldPositionChangedEventArgs e) { //3 Other columns can be fixed. // ensure that the first filed name will be always on first place if (e.Field.ActualPosition.Column == 0) { xamDataGrid1.FieldLayouts[0].Fields["name"].ActualPosition = new Infragistics.Windows.DataPresenter.FieldPosition(0, 0, 1, 1); xamDataGrid1.FieldLayouts[0].EnsureUniqueFieldPositions(); } } private void xamDataGrid1_FieldPositionChanging(object sender, Infragistics.Windows.DataPresenter.Events.FieldPositionChangingEventArgs e) { //1 One particular column (let's call it A) must always remain the left-most column. //2 Other columns can be fixed. if (e.Field.Name == "name") { e.Cancel = true; } }
private void xamDataGrid1_FieldPositionChanged(object sender, Infragistics.Windows.DataPresenter.Events.FieldPositionChangedEventArgs e)
{
//3 Other columns can be fixed.
// ensure that the first filed name will be always on first place
if (e.Field.ActualPosition.Column == 0)
xamDataGrid1.FieldLayouts[0].Fields["name"].ActualPosition = new Infragistics.Windows.DataPresenter.FieldPosition(0, 0, 1, 1);
xamDataGrid1.FieldLayouts[0].EnsureUniqueFieldPositions();
}
private void xamDataGrid1_FieldPositionChanging(object sender, Infragistics.Windows.DataPresenter.Events.FieldPositionChangingEventArgs e)
//1 One particular column (let's call it A) must always remain the left-most column.
//2 Other columns can be fixed.
if (e.Field.Name == "name")
e.Cancel = true;
Your case number is CAS-60747-Z3FKRB you can also contact me via case if you need any further assistance.
Sincerely,DimiDeveloper Support Engineer, MCPD Infragistics, Inc.www.infragistics.com/support
That's correct.
Thank you for your help.
Hello croesusdev,
Just to clarify the requirements:
* One particular column (let's call it A) must always remain the left-most column.* Other columns can be fixed.* Other columns can be dragged, but not to the left of column A.
The Developer Support staff should be able to assist you in implementing this functionality. There is already a case created for you.
Elizabeth AlbertLocalization Engineer
Thanks, I tried your sample. Your right, it works in this particular case.
But if you have more than 1 column in the fixed section, you can switch them together.
And I also need to enable the column fixing fonctionnality has it is shown in the feature browser.
In fact, I need complexe behavior has it is shown in the feature browser.
Yes, I see that now in the Feature Browser under xamDataGrid > Layout and Behavior > Fixed Fields. However, that is a more complex sample than the one I made. I have attached my sample. Could you please try to run that (I used 10.3 but you can change the assembly references to match the ones you have installed), and let me know if it fits your requirements?