Telerik Forums
UI for WPF Forum
1 answer
104 views
Hi all,

I want to interface the Telerik RadGridView control with some data on my SQL Server backend. At the moment I am deciding the best method to do this, what I want to do on the grid is to have regions where user input is allowed (editable) and regions where it is only read only. Users will need to be able to change the editable values (which are pulled from the database) and these changes will need to be updated into the database, then used to recalculated (on the client end) and then reflected in the read only regions of the grid.

At the moment I've written functionality to get data from the database (LINQ TO SQL) and then individually create rows which are inserted into a data table which is then bound to the RAD datagrid. Will I be able to control the properties of each row this way? For example having some rows editable, some read only and also styling options such as cell back ground colour, font bolding etc.

I apologise if my description is very vague but it's the best way I can explain it at the moment!

Thanks in advance!

Tim.
Stefan Dobrev
Telerik team
 answered on 30 Oct 2009
1 answer
128 views
Hi All.

I have an XML and I need to create the GridView based on it's content. I need to be able to add rows to the GridView manually in code. No DataView or DependencyProperties. Would appreciate a code example. The headers was easy to create, only need the rows themselves.

Regards
 Kjetil
Vlad
Telerik team
 answered on 30 Oct 2009
4 answers
196 views
Please help me!!!!

Hi guys!!!, Im realy scared in my RadGrid appear a ghost row, when this show 2 or more rows whit child, this event takes place when in other RadGrid changes the selection item, attach image, my code for this radGrid is the next:
                    DataTable _dtStudy =  wpfWebServexCore.ServiceGeneralClass.studys(((DataRow)rgvPatients.SelectedItem).ItemArray[0].ToString());
                    _idPatient = ((DataRow)rgvPatients.SelectedItem).ItemArray[0].ToString();
                    rgvSeries.ItemsSource = _dtStudy;
                    rgvSeries.DataMember = _dtStudy.TableName;
                    if (rgvSeries.TableDefinition.ChildTableDefinitions.Count > 0)
                    {
                        for (int i = 0; i < rgvSeries.TableDefinition.ChildTableDefinitions.Count; i++)
                        {
                            rgvSeries.TableDefinition.ChildTableDefinitions.RemoveAt(i);
                        }
                    }

                    foreach (DataRow _dr in _dtStudy.Rows)
                    {
                         
                        GridViewTableDefinition definition = new GridViewTableDefinition();
                        definition.AutoGenerateFieldDescriptors = false;
                        definition.DataSource = wpfWebServexCore.ServiceGeneralClass.series(_dr["StudyInstanceUID"].ToString());

                        //rgvSeries.UpdateLayout();

                        TableRelation _relation = new TableRelation();
                        _relation.FieldNames.Add(new FieldDescriptorNamePair("StudyInstanceUID", "StudyInstanceUID_FKey"));
                        definition.Relation = _relation;

                        rgvSeries.TableDefinition.ChildTableDefinitions.Add(definition);
                       
                        rgvSeries.AddHandler(GridViewDataControl.RowValidatingEvent, new EventHandler<GridViewRowValidatingEventArgs>(this.selectChild_clik));
                        
                    }
                    ((ExpandableDataRecord)rgvSeries.Records[0]).IsExpanded = true;
                    wpfWebServexCore.ClassGlobal.DtStudy = _dtStudy;
                    rgvImages.ItemsSource = new DataTable();

AND the XAML

 <telerik:RadGridView Height="auto" Name="rgvSeries" Width="auto" SelectionChanged="rgvSeries_SelectionChanged" ShowGroupPanel="False" IsFilteringAllowed="False" telerik:StyleManager.Theme="Office_Black" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding}" MouseDoubleClick="buttonAbrirEstudio_Click" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" Background="White" ColumnsWidthMode="Fill" HorizontalAlignment="Right" VerticalAlignment="Top">
                                <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn HeaderText="UID" UniqueName="StudyInstanceUID" DataType="{x:Null}"   IsVisible="False" />
                                <telerik:GridViewDataColumn HeaderText="Fecha" UniqueName="Fecha" DataType="{x:Null}"  />
                                <telerik:GridViewDataColumn HeaderText="Descripción" UniqueName="Descripcion" DataType="{x:Null}"  />
                                <telerik:GridViewDataColumn HeaderText="Modalidad" UniqueName="Modalidad" DataType="{x:Null}"  />
                                <telerik:GridViewDataColumn HeaderText="Medico" UniqueName="Medico" DataType="{x:Null}"  />
                                <telerik:GridViewDataColumn HeaderText="Reporte" UniqueName="Reporte" DataType="{x:Null}"  />
                            </telerik:RadGridView.Columns>
                                    
                            <telerik:RadGridView.HierarchyChildTemplate>
                                <DataTemplate>
                                    <Border BorderBrush="#FFFDDFAA" BorderThickness="2" Margin="20,2">
                                      
                                       
                                        <telerik:RadGridView x:Name="rgvhijoSerie" IsFilteringAllowed="False" ShowGroupPanel="False" IsReadOnly="True" SelectionChanged="rgvhijoSerie_SelectionChanged" MouseDoubleClick="buttonAbrirEstudio_Click" RowIndicatorVisibility="Collapsed"  CanUserFreezeColumns="False" ShowColumnHeaders="False" Background="White" GridLinesVisibility="None">                                            
                                            <telerik:RadGridView.Columns>
                                                <telerik:GridViewDataColumn HeaderText="UID" UniqueName="StudyInstanceUID" DataType="{x:Null}"  IsVisible="False" />
                                               

                                                <telerik:GridViewDataColumn HeaderText="Fecha" UniqueName="" DataType="{x:Null}" Width="auto" IsVisible="False"  />
                                                <telerik:GridViewDataColumn HeaderText="Descripción" UniqueName="Descripcion" DataType="{x:Null}" Width="auto" />
                                                <telerik:GridViewDataColumn HeaderText="Modalidad" UniqueName="" DataType="{x:Null}" Width="auto" IsVisible="False"/>
                                                <telerik:GridViewDataColumn HeaderText="Medico" UniqueName="" DataType="{x:Null}" Width="auto" IsVisible="False" />
                                                <telerik:GridViewDataColumn HeaderText="Reporte" UniqueName="" DataType="{x:Null}" Width="auto" IsVisible="False" />

                                            </telerik:RadGridView.Columns>                                            
                                        </telerik:RadGridView>
                                        
                                       
                                    </Border>
                                </DataTemplate>
                            </telerik:RadGridView.HierarchyChildTemplate>                            
                        </telerik:RadGridView>
 

Pleas help me, or can you give me any idea

Regards!!
Armando
Top achievements
Rank 1
 answered on 29 Oct 2009
1 answer
206 views
I want to change foreground color of a column STATUS cell value  in a grid such that if STATUS=Available then text should appear in Green else in Red.I applied the style ,while debugging Convert method is debuggung sucessfully reading correct value but doesn't show up on grid.

 <Converter:DocumentColorConverter  x:Key="ConvertDocumentColor" />

                                                                            <Style TargetType="{x:Type telerik:GridViewCell}">
                                                                                <Setter Property="Foreground" Value="{Binding [STATUS], Converter={StaticResource ConvertDocumentColor}}" />
                                                                            </Style>
 public class DocumentColorConverter : IValueConverter
    {

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Windows.Media.Brush returnValue;
            string controlType = "";
            if (value != null)
                controlType = value.ToString();

            switch (controlType)
            {
                case "Available":
                    returnValue = Brushes.Green;
                    break;
                case "UnAvailable":
                    returnValue = Brushes.Red;
                    break;
                default:
                    returnValue = Brushes.Black;
                    break;

            }

            return returnValue;
        }

        #endregion

        #region IValueConverter Members


        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

Pavel Pavlov
Telerik team
 answered on 29 Oct 2009
2 answers
330 views
Hello,

I ran into a problem when adding a columns thru code. It seemed to work fine in the 2009 Q3 Beta 1 version. basically i'm adding the columns in codebehind then later on i'm adding data to the grid. When I do that the filters dont show up on the Column Headers.

here is some sample code.
<Window x:Class="WpfApplication1.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Group Chart Test">  
    <Grid>          
        <Grid.RowDefinitions> 
            <RowDefinition /> 
            <RowDefinition Height="30" /> 
        </Grid.RowDefinitions> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition /> 
            <ColumnDefinition /> 
        </Grid.ColumnDefinitions> 
        <telerik:RadGridView Name="rgv"   
                             AutoGenerateColumns="False" 
                             Grid.Row="0" 
                             Grid.ColumnSpan="2"/>  
 
        <Button Click="Button_Click"   
                Grid.Row="1"   
                Grid.Column="0" 
                Content="Add Columns"/>  
        <Button Click="Button_Click_1"   
                Grid.Row="1" 
                Grid.Column="1" 
                Content="Add Items"/>  
    </Grid> 
</Window> 
public partial class Window1 : Window  
    {  
 
        ArrayList arrayList = new ArrayList();  
        public Window1()  
        {  
            try 
            {  
 
                InitializeComponent();  
 
                for (int i = 0; i < 100; i++)  
                {  
                    arrayList.Add(new myObject()  
                    {  
                        Year = 2002,  
                        Quarter = "First",  
                        Make = "Chevrolet",  
                        Sales = 1000  
                    });  
                }  
            }  
            catch (Exception ex)  
            {  
                MessageBox.Show(ex.ToString());  
            }  
        }  
 
        private void Button_Click(object sender, RoutedEventArgs e)  
        {  
            rgv.Columns.Add(new GridViewDataColumn()  
            {  
                UniqueName = "Year",  
                Header = "Year" 
            });  
 
            rgv.Columns.Add(new GridViewDataColumn()  
            {  
                UniqueName = "Quarter",  
                Header = "Quarter" 
            });  
 
            rgv.Columns.Add(new GridViewDataColumn()  
            {  
                UniqueName = "Make",  
                Header = "Make" 
            });  
 
            rgv.Columns.Add(new GridViewDataColumn()  
            {  
                UniqueName = "Sales",  
                Header = "Sales" 
            });  
        }  
 
        private void Button_Click_1(object sender, RoutedEventArgs e)  
        {  
            rgv.ItemsSource = arrayList;  
        }  
    }  
 
    class myObject  
    {  
        public int Year { getset; }  
        public String Quarter { getset; }  
        public String Make { getset; }  
        public double Sales { getset; }  
    } 

if I set the DataType of the column the filters show up. Not sure if its a bug or not but thought i would ask.

Thanks Again,
Boots
Stefan Dobrev
Telerik team
 answered on 29 Oct 2009
1 answer
59 views
Hi, in every row of my RadGridView appears a circle, and in  the child too. I attach an image where you can see it.
Vlad
Telerik team
 answered on 29 Oct 2009
1 answer
193 views
I want to not to show horizontal scroolbar on grid .I used this style but doesn't work
<Style TargetType="{x:Type telerik:GridViewScrollViewer}">
                                                            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
                                                        </Style>
Hristo
Telerik team
 answered on 28 Oct 2009
1 answer
160 views
So, we are using an older version of the Grid control.  Kinda stuck with it for now because we are at the very end of product development and we can't afford to be changing anything at this point.

I have had an annoying problem for awhile that has been a lower bug issue, but now I'm finally getting to it.

I'm assuming the developers used this method of binding data to the cell because this was the only way to use a converter. But this is messing up the default cell style. the cell doesn't look like the other cells. It's kinda a pain to go into every instance of the grid we are using in the application and fix the style where they have overridden the template.

Question: Is this the best way to do this? Is there a better way to do this binding without overriding the template?  Again, we can't update the control. We are stuck with 2009.1.312.35 for now. 


<
telerik:GridViewDataColumn UniqueName="UserNames" 
                                                    HeaderText="{x:Static properties:Resources.Population_GridHeader_UserName}"
                            <telerik:GridViewColumn.CellStyle> 
                                <Style TargetType="{x:Type telerik:GridViewCell}"
                                    <Setter Property="Template"
                                        <Setter.Value> 
                                            <ControlTemplate TargetType="{x:Type telerik:GridViewCell}"
                                                <Border BorderThickness="{TemplateBinding BorderThickness}" 
                                                        BorderBrush="{TemplateBinding BorderBrush}" 
                                                        Background="{TemplateBinding Background}"
                                                    <TextBlock Text="{Binding Path=UserNames, Mode=OneWay, Converter={StaticResource UserNameListToStringConverter}}" 
                                                               VerticalAlignment="Center" 
                                                               Margin="5" /> 
                                                </Border> 
                                            </ControlTemplate> 
                                        </Setter.Value> 
                                    </Setter> 
                                </Style> 
                            </telerik:GridViewColumn.CellStyle> 
                        </telerik:GridViewDataColumn> 
Vlad
Telerik team
 answered on 28 Oct 2009
6 answers
149 views
Hi,
I have bound the GridView to an collection of business-objects that have a IsSelected-Property(bool) and an according CheckBox-Column.
To be able to change this property for all objects in a group I came up with this:
 
<Style x:Key="CustomRowStyle"  TargetType="telerik:GridViewGroupRow"
    <EventSetter Event="Loaded" Handler="GridViewGroupRow_Loaded" /> 
</Style> 
 
        private void GridViewGroupRow_Loaded(object sender, RoutedEventArgs args) 
        { 
            GridViewGroupRow groupRow = (GridViewGroupRow)args.OriginalSource; 
 
            CheckBox cb = new CheckBox() { Content = groupRow.Group.Key }; 
 
            cb.Tag = groupRow
 
            cb.Checked += new RoutedEventHandler(groupRow_CheckChanged); 
            cb.Unchecked += new RoutedEventHandler(groupRow_CheckChanged); 
 
            groupRow.Header = cb
        } 
 
 
 
        void groupRow_CheckChanged(object sender, RoutedEventArgs e) 
        { 
            GridViewGroupRow groupRow = (sender as CheckBox).Tag as GridViewGroupRow; 
 
            recursiveGroupSelection(groupRow.Group, (sender as CheckBox).IsChecked ?? false); 
        } 
 
        private void recursiveGroupSelection(IGroup g, bool check) 
        { 
            foreach (var item in g.Items)//select items in this group 
            { 
                if (item is BusinessObject) 
                { 
                    (item as BusinessObject).IsSelected = check
                } 
            } 
             
            //the same for all subgroups 
            foreach (Group sub in g.Subgroups) 
            { 
                recursiveGroupStationSelection(sub, check); 
            } 
        } 
1. This checks and unchecks all items in the group and subgroups but I do not know how to get to the GridViewGroupRow of the subgroups and also (un)check their CheckBoxes. I can get the Group from GridViewGroupRow but when walking down the subgroups I do not know how to get their GridViewGroupRows.
2. I also wasn't able to get the PropertyName from the Group - the Group's Key-Property is the actual property's value. How to get the property's name to know what property is grouped by this Group?
3. And it would be very nice if (un)checking items would be reflected in the parent-group-checkbox(es).

Any suggestion is welcome.

Best Regards
Steffen
Pavel Pavlov
Telerik team
 answered on 27 Oct 2009
1 answer
171 views
Hello,

I am developing an user control in wpf. In which I am using RadCombobox.

<telerikComboBox:RadComboBox SelectedIndex="0" IsEditable="True" IsReadOnly="True"  DisplayMemberPath ="ActiveListName" x:Name="cmbActiveList"  Margin="0,-2,0,0" ItemsSource="{Binding}" Width="142" HorizontalAlignment="Left"  Background="{x:Null}" BorderBrush="{x:Null}" FontSize="11"  Height="20" IsMouseWheelEnabled="True" Foreground="#FF000000"  />

this the code which I am writting for combobox. Now I want to change list background color which is white by default.

For combobox I am using Foreground color as white so I am not able to view text. So can you provide me some code or help by which I can change list appearance form white to dark gray of something like that???

Hoping for early reply......
Valeri Hristov
Telerik team
 answered on 27 Oct 2009
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?