Hi..I m using infragistics xamdatagrid.
I m binding data from an xml file using xmldataprovider in grid.resources.
data is displaying in the grid nicely.my problem is when we bind the data the field header names it wil take from the xml file.
here we can give our own field header using filed label.i gave same like this.but field headers not changing..
<igDP:Field Name="CountyId" Label="COUNTRYID" />
here name means name in the xml file right. label means we can give what header we want for that field..
i gave same like this .but not coming.can u give reply for this..
i wil send some code also for this wat i wrote..
Here i m facing many small small problems.
1)Here I gave Label name in CAPITAL letters.but its not taking.it is displaying same as in the xml file.
2)Here i gave editastype is Int32. but it is taking string values also.
3)and i gave field width 30. it is not taking.
4)overall its not taking field layoutsettings.so it is not applying wat i gave inside this.
Please give reply.......
<
Grid.Resources ><XmlDataProvider x:Key="CountryData XPath="/Countries/Country"
Source="C:\Sample.xml"></XmlDataProvider></Grid.Resources>
igDP:XamDataGrid Name="MainDataGrid"
DataSource
="{Binding Source={StaticResource CountryData},XPath=/Country}">
igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowSummaries="True" SummaryUIType="MultiSelect" SummaryDisplayArea="Bottom">
</igDP:FieldSettings></igDP:XamDataGrid.FieldSettings>
igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout >
<igDP:FieldLayout.Fields>
<igDP:Field Name="CountryId" Label="COUNTRYID" >
<igDP:Field.Settings>
<igDP:FieldSettings EditAsType="{x:Type sys:Int32}" AllowResize="False"
CellWidth="30"></igDP:FieldSettings></igDP:Field.Settings></igDP:Field>
</
igDP:FieldLayout.Fields></igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Hello,
This is true - the name has to be exactly the same as the one in the source. So to make sure that you have exactly the same names and really a quick way to do this is to use the trick that Josh Smith has shown in his blog post here.
Using this, you will get all the fields generated automatically in the output and just copy and paste them and then set the appropriate labels.
I would also suggest setting EditAsType not EditAsType so that the proper editor can be picked up for this field.
Once you have defined the fields in the xaml, make sure you turn off the AutoGenerateFields property in the FieldLayoutSettings.
Test this and let me know if you still have problems.
Alex.
Hi Alex..
Thanks for ur quick reply..my all problems solved.it works fine..
one more doubt..when i enter data in field the value sholud be between 1 and 100.
how can i write this condition in <igDP:fiedsettings />..
or else i have to write in c# code??
can u suggest some answer..
In this case, I could go couple of ways:
1. You can set ValueConstraint property (create a style for the ValueEditor (i.e. XamNumericEditor)) in the Field and set Max and Min~Exclusice/Inclusive.
2. You can also handle the EditModeEnded event to check for the value of the cell.
3. You can create a converter (IValueConverter) and perform this logic there.
Hope this helps,
Hi alex..
thanks for ur reply.
can u please give some sample code any one of these..
i dont know how to use xamnumericeditor in the field...
thanks in advance.
Please follow the link below to see how to set ValueConstraint of an editor:
http://forums.infragistics.com/forums/p/22366/81681.aspx#81681
In your scenario, you should create a style for the XamNumericEditor and the style should have not x:key set
<Style TargetType="{x:Type igEditors:XamNumericEditor}"><Setter Property="ValueConstraint"><Setter.Value><igEditors:ValueConstraint MinInclusive... MaxInclusive..../>
....
hi alex ..thanks 4 ur reply.
but this way wil not work for me.because i m using express version.not full version .
so can u please give answer for editmode ended event..
thanks in advance..
As you are using the express version, you will be having only XamTextEditors.
In this case you can use the following
string oldValue;
...
void xamDataGrid1_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e)
{
int a;
if (int.TryParse(e.Cell.Value.ToString(), out a))
if (a > 10)
e.Cell.Value = oldValue; // revert to the old value
}
void xamDataGrid1_EditModeEnding(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndingEventArgs e)
if( int.TryParse(e.Cell.Value.ToString(),out a))
oldValue = a.ToString(); //save the old value
Let me know if you have questions on this.
I suppose the scenario is the same with ListView or XamDataGrid. I did not undestand if you managed or not to insert the combo into the grid. You can see an example of that in the XamFeatureBrowser -> Control Composition section.
Thank u very much alex...
it works fine...next one more question...
I want to place one combobox in this xamgrid.this combobox items will be taken from one xml file .means i want all country names in that..
i tried this one using listview gridview.it worked fine.but it is giving 9 comboboxes because i have 9 rows in that xml file.but combobox is taking only country names.but 9 times combobox repeating in the gridview. because i gave listview itemsource is xmlprovider key name and xpath also i gave.if i dont give means listview is empty.not displaying any data.so i gave itemssource ot listview.its displaying 9 times.
so now i want to use this one in xamdatagrid.so now i want to place one combobox in the field.
and the itemssource for this combobox is xmlfile county names.
can u please give reply for listview also if i did any mistake for taking itemssource..
thank u in advacne..