Hi..
I have created xamdatagrid with some data.
it has 10 rows and 10 colums.
Now i want to enable cells only from column 4 to 7 for a perticular record.
I want to do like this for every record which series of cells i want to enable means it wil enable.
remaining cells should be disabled.
Can u suggest answer for this.
And one more thing.Xamfeature browser examples are helpful.
But in that c# code you are using Strings class.
What is that class..what are that properties..
If i try to use tat program individually means in xaml code u have used that Strings class properties.
How to use that Strings class in our project.??
Thank u very much.
Hi GDU,
You can find a lot of information from the XamDataGrid documentation. I tend to peruse the API Overview for more specific information.
Hope that helps!
Arron et al,
I am struggling with a simlar thread to the above. My final goal is to IsEnabled = false a single cell on the grid. This is based on the value from another column. All is working except the disable a single cell part. No matter what I've tried (below), the CellValuePresenter comes back null or sets all of the cells for that field to IsEnabled = true.
1. Why is the cvp always null when the record is valid and has content?
2. Why do all of the records in the field become disabled when I am clearly (or not) targeting just one?
The code below works to comments just the items in my group, but the problem is this code disables the entire row, not simply the cell I want to disable. Everything else I have commented below has been tried but does not work.
Thanks,
Glenn
foreach (Infragistics.Windows.DataPresenter.Record rec in gbr) { if (!rec.IsExpanded && rec.Description.StartsWith("RTO-R")) { rec.IsExpanded = true; var children = rec.ViewableChildRecords.ToList(); int totalNumRecs = children.Count;
foreach (DataRecord child in children) { //DataRecord currentRow = child as DataRecord; //CellValuePresenter cvp = CellValuePresenter.FromRecordAndField(child, child.FieldLayout.Fields[8]); //CellValuePresenter cvp = CellValuePresenter.FromCell(child.Cells[8]); //CellValuePresenter cvp = CellValuePresenter.FromRecordAndField(child, child.FieldLayout.Fields[8]); //cvp.IsEnabled = false;
((Infragistics.Windows.DataPresenter.Cell)(child.Cells.Record.Cells.Record.Cells[8])).Record.IsEnabled = false;
//CellValuePresenter cvp = child.DataPresenter.ActiveRecord.FieldLayout.Fields[8] as CellValuePresenter; //cvp.Record.Cells[8].Field.Settings.AllowEdit = false; //Record cvpRecord = cvp.Record; //cvpRecord.IsEnabled = false; //currentRow.Cells[8].Record.Cells[8].Field.Settings.AllowEdit = false; //child.FieldLayout.Fields[8].Settings.AllowEdit = false; }
} }
Hello Glenn,
When you call ViewableChildRecords of a DataRecord you are getting the ExpandableFieldRecordPresenter and not the nested records. To get the nested records, you have to do this twice like this:
rec. ViewableChildRecords[0]. ViewableChildRecords.ToList();
The CellValuePresenter might be null if you are calling this in an event that is too early for the Presenters to be generated or when the CellValuePresenter is not in view.I can see this is fairly simple condition, which can be easily done in xaml and you will not have to iterate through all of the records. Do you have to do this in procedural code?
Alex,
No, it is not necessary I do this in code behind. If you have a way with CVP, that would be great. I have two conditions.
1. Compare one cell to the value of another and if the other cell has "somevalue" then disable cell "other"
2. Same as one but based on datetime.
Glenn,
One way to do this in xaml is with DataTrigger:
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="cvp">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Cells[department].Value}" Value="Admin">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
The other way would be using IValueConverter, like this:
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="IsEnabled">
<Setter.Value>
<Binding Converter="{StaticResource conv}" Path="Record.Cells[2].Value" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}"/>
</Setter.Value>
</Setter>
I am attaching a sample which uses both approaches - bind with DataTrigger and with converter. They are for the foreground property, but you can modify it to work for the IsEnabled property.
Let me know if you have questions on this.
A few observations. Attempting to use the below to call the value converter in the example does not resolve the value of the cell. It simply passes the object value as "Text". Text is not a color, so it's not picking it up from the field.
Using the Xaml Approach disabled the entire row rather than the more desirable cell only.
<local:TextToColorConverter x:Key="conv"/> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Foreground"> <Setter.Value> <Binding Converter="{StaticResource conv}" Path="Record.Cells[2].Value" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type igDP:DataRecordPresenter}}"/> </Setter.Value> </Setter> </Style>
Even though I created the sample and the third option (handling events) I do not recommend it :) - as you can see that approach needs fine tuning in different scenarios.
I am going to create a support case on your behalf so you can give me more details on your scenario and I will be glad to look into your scenario deeper and come up with a fine working solution for you.
You've got me a bit lost. VB is also a foreign language for me. If I catch your drift you want to change specific cells based on either a cell position or value of another cell or color of your shirt etc? Is that correct? Naturally, what else is there? I guess you could change it based on phases of the moon...
Any-who...
Yes, CVP is the way to go. I always use a Style Converter and a separate class for the Converter. Whence you pass the value you are looking for, you simply validate it and act on it. I've attached one example of mine. Yes, a value could be a position in your case?
In this example I'm doing 3 or 4 CVP checks (based on value, not position) and conversions. Hope you can sort out just one. If reading this is confusing, it should be, it's complex.
sorry i forget put event
Private
xamgrdrocpenpagos.CellActivated
hello
can you please explain me how can do cell image dinamic
= xamgrdrocpenpagos.ActiveCell.Record.Index
Infragistics.Windows.DataPresenter.Record = xamgrdrocpenpagos.Records(int)
Infragistics.Windows.DataPresenter.DataRecord = record
Infragistics.Windows.DataPresenter.Cell = record1.Cells(0)
Infragistics.Windows.DataPresenter.FieldSettings = record1.FieldLayout.Fields(0).Settings
r.CellValuePresenterStyle = xamgrdrocpenpagos.Resources.Keys(1)
i don´t know which mistake.
Thanks.
Hello,
I did not understand your requirement. You are using the CellActivated event but I am not sure what you want to do in it. Can you give us more information on that?
I want to change cell by value but i can´t . can you help me.
XamDataGrid1.CellActivated
= e.Cell.DataPresenter.ActiveRecord.Index
how can change content row and col ????