Telerik Forums
UI for WinForms Forum
3 answers
173 views

I am attempting to build hierarchy in a grid from business objects. If I select ‘Auto Generate Hierarchy’ and ‘Auto Generate Columns’ it does work.  Expanding a parent row shows its related children in RadGrid.

However, when I attempt to programmatically build the relation it does not work. Expanding a parent row does not show its related children.

I have followed the GridView Object Relational Hierarchy Mode documentation word for word without success.  I have used ‘property builder’ of the grid as per the tutorial but that did not help either.

Here is a sample code:

        private void FormEventStaffPlans_Load(object sender, EventArgs e)
        {
            // --------- Parent -----------
            // Staff plan unique identifier.
            GridViewDecimalColumn dColumn = new GridViewDecimalColumn("StaffPlanId");
            dColumn.HeaderText = "StaffPlanId";
            dColumn.IsVisible = false;
            dColumn.ReadOnly = true;
            this.radGridViewStaffPlans.Columns.Add(dColumn);
 
            // Total required staff.
            dColumn = new GridViewDecimalColumn("NumberOfStaffPerShift");
            dColumn.HeaderText = "Staff Req";
            this.radGridViewStaffPlans.Columns.Add(dColumn);
 
            // Total male
            dColumn = new GridViewDecimalColumn("NumberOfMalePerShift");
            dColumn.HeaderText = "Male";
            this.radGridViewStaffPlans.Columns.Add(dColumn);
 
            // Total female
            dColumn = new GridViewDecimalColumn("NumberOfFemalePerShift");
            dColumn.HeaderText = "Female";
            this.radGridViewStaffPlans.Columns.Add(dColumn);
 
            // Employee Id (TO DO: change this to dropdown box)
            dColumn = new GridViewDecimalColumn("EmployeeId");
            dColumn.HeaderText = "Empoloyee";
            this.radGridViewStaffPlans.Columns.Add(dColumn);
 
            // Labour hire company Id (TO DO: change this to dropdown list)
            dColumn = new GridViewDecimalColumn("HireCompanyId");
            dColumn.HeaderText = "HireCompanyId";
            this.radGridViewStaffPlans.Columns.Add(dColumn);
            this.radGridViewStaffPlans.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
            // --------- Child -----------
 
            // Create child template (for staff shifts)
            GridViewTemplate childTemplate = new GridViewTemplate();
            this.radGridViewStaffPlans.Templates.Add(childTemplate);
 
            // Set columns of child template
            // Shift unique identifier.
            dColumn = new GridViewDecimalColumn("ShiftId");
            dColumn.HeaderText = "ShiftId";
            dColumn.IsVisible = false;
            dColumn.ReadOnly = true;
            childTemplate.Columns.Add(dColumn);
 
            // Shift from (display date only).
            GridViewDateTimeColumn dtColumn = new GridViewDateTimeColumn("ShiftFrom");
            dtColumn.Format = DateTimePickerFormat.Short;
            dtColumn.HeaderText = "Date From";
            childTemplate.Columns.Add(dtColumn);
 
            // Shift to (display date only).
            dtColumn = new GridViewDateTimeColumn("ShiftTo");
            dtColumn.Format = DateTimePickerFormat.Short;
            dtColumn.HeaderText = "Date To";
            childTemplate.Columns.Add(dtColumn);
 
            // Shift from (display time only).
            dtColumn = new GridViewDateTimeColumn("ShiftFrom");
            dtColumn.Format = DateTimePickerFormat.Time;
            dtColumn.HeaderText = "Shift Start";
            childTemplate.Columns.Add(dtColumn);
 
            // Shift to (display time only).
            dtColumn = new GridViewDateTimeColumn("ShiftTo");
            dtColumn.Format = DateTimePickerFormat.Time;
            dtColumn.HeaderText = "Shift End";
            childTemplate.Columns.Add(dtColumn);
 
            // Shift part.
            dColumn = new GridViewDecimalColumn("ShiftPart");
            dColumn.HeaderText = "Shift Part";
            childTemplate.Columns.Add(dColumn);
 
            // Break duration.
            dColumn = new GridViewDecimalColumn("BreakDuration");
            dColumn.HeaderText = "Break Duration";
            childTemplate.Columns.Add(dColumn);
 
            // Variation code.
            GridViewTextBoxColumn tColumn = new GridViewTextBoxColumn("VariationCode");
            tColumn.HeaderText = "Variation Code";
            childTemplate.Columns.Add(tColumn);
 
            // Shift cost.
            dColumn = new GridViewDecimalColumn("ShiftCost");
            dColumn.HeaderText = "Shift Cost";
            dColumn.ReadOnly = true;
            childTemplate.Columns.Add(dColumn);
 
            // Shift cost type.
            tColumn = new GridViewTextBoxColumn("ShiftCostType");
            tColumn.HeaderText = "Shift Cost Type";
            dColumn.ReadOnly = true;
            childTemplate.Columns.Add(tColumn);
 
            // Area (TO DO: change this to dropdown list).
            dColumn = new GridViewDecimalColumn("AreaId");
            dColumn.HeaderText = "Area";
            childTemplate.Columns.Add(dColumn);
 
            // Shift type.
            tColumn = new GridViewTextBoxColumn("ShiftType");
            tColumn.HeaderText = "Shift Type";
            childTemplate.Columns.Add(tColumn);
 
            childTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
            // Add the relation between parent (staff plans) and the child (staff plan shifts)
            GridViewRelation relation = new GridViewRelation(this.radGridViewStaffPlans.MasterTemplate,                                 childTemplate);
            relation.ChildColumnNames.Add("EventShift");
            this.radGridViewStaffPlans.Relations.Add(relation);
 
            // Add data source to grid (parent).
            IList<EventStaffPlan> list = _siteProxy.GetEventStaffPlans(34);
            this.radGridViewStaffPlans.DataSource = list;
        }
 
 
    public class EventStaffPlan:BusinessObject
    {
        /// <summary>
        /// Default constructor for EventStaffPlan class.
        /// </summary>
        public EventStaffPlan() { }
        /// <summary>
 
        /// Overloaded constructor for EventStaffPlan class.
        /// Initialises automatic properties.
        /// </summary>
        /// <param name="staffPlanId">Staff plan unique identifier.</param>
        /// <param name="numberOfStaffPerShift">Total number of staff per shift.</param>
        /// <param name="numberOfMaleStaffPerShift">Number of male staff per shift.</param>
        /// <param name="numberOfFemaleStaffPerShift">Number of female staff per shift. </param>      
        /// <param name="employeeId">Employee unique identifier.</param>
        /// <param name="hireCompanyId">Hire company unique identifier.</param>
        /// <param name="eventShift">List of EventStaffShift objects.</param>
        public EventStaffPlan(int staffPlanId, int numberOfStaffPerShift, int numberOfMaleStaffPerShift,                int numberOfFemaleStaffPerShift, int employeeId, int hireCompanyId,             IList<EventStaffShift> eventShift)
        {
            StaffPlanId = staffPlanId;
            NumberOfStaffPerShift = numberOfStaffPerShift;
            NumberOfMalePerShift = numberOfMaleStaffPerShift;
            NumberOfFemalePerShift = numberOfFemaleStaffPerShift;          
            EmployeeId = employeeId;
            HireCompanyId = hireCompanyId;
            EventShift = eventShift;
        }
 
        /// <summary>
        /// Gets or sets staff plan unique identifier.
        /// </summary>
        public int StaffPlanId { get; set; }
 
        /// <summary>
        /// Gets or sets total number of staff per shift.
        /// </summary>
        public int NumberOfStaffPerShift { get; set; }
 
        /// <summary>
        /// Gets or sets number of male employees per shift.
        /// </summary>
        public int NumberOfMalePerShift { get; set; }
 
        /// <summary>
        /// Gets or sets number of female employees per shift.
        /// </summary>
        public int NumberOfFemalePerShift { get; set; }
 
        /// <summary>
        /// Gets or sets employee unique identifier.
        /// </summary>
        public int EmployeeId { get; set; }
 
        /// <summary>
        /// Gets or sets hire company unique identifier.
        /// </summary>
        public int HireCompanyId { get; set; }
 
        /// <summary>
        /// Gets or sets list of event staff plan shift objects.
        /// </summary>
        public IList<EventStaffShift> EventShift { get; set; }
    }



Class EventStaffShift does not have any related lists.
Working with version: 2011.1 11.419

Julian Benkov
Telerik team
 answered on 10 Jun 2011
4 answers
157 views
Hi
Sir/Madam,


I attached 2 files,
in 1st file ,grid is exactly fit into screen . it is OK , but

in 2nd file , when  i perform group by  grid size is decreasing and it is not looking good

Can any one help me about this asap.


Thanks&Regards

Saikiran
Svett
Telerik team
 answered on 10 Jun 2011
3 answers
103 views
Using 2009.3.9.1203 version of RadGridView.
When I load a grid layout with LoadLayout and the grid has grouping, the topmost group does not sync with the grid until the user clicks on the group header. Top + n level subgroups work fine. None of the routines to collapse or expand groups works for the top group. Manually adding and removing the group does not work.

Martin Vasilev
Telerik team
 answered on 10 Jun 2011
1 answer
115 views
Forgive me if I am missing something. I was using the NodeMouseUp event to detect when a node was checked or unchecked. The reason I used this and not the NodeCheckedChanged is that NodeMouseUp only fires once whereas NodeCheckedChanged fires for every node checked and when you select the parent node it fires for every child node. The NodeMouseUp worked fine till I upgraded to Q1 2011. Perhaps there is a better way to do what I want. I simply want to know when the selections for the entire tree have been changed and then refresh my GridView based on the values. 

Thank You
Svett
Telerik team
 answered on 10 Jun 2011
1 answer
125 views
Hi guys,

I'm looking for  a quick way to find a record based on one or several values in the grid, datasource for the gridview could be 100 thousand records or more (tied into inventory items for a large grocery store). Telerik gridview is used for a lookup,basically a seed value get's passed to the grid and it needs to locate the record (aka Row) and highlight it.

Could some direct me to right location of an example that would demonstrate the required functionality? Help is appreciated. Thank you.
Stefan
Telerik team
 answered on 10 Jun 2011
1 answer
123 views
Thanks in advance for any assistance.

What event would I use to grab the GridRowInfo when the navigates to a another row? I'm working with the RowsChanged event and it's firing after -each- change to the row when evaluating the NotifyCollectionChangedAction.ItemChanged enum.

Essentially, what I need to do, is if any value in the row changes, I need to get the row and update the database. If I use the RowsChanged event, I potentially would be updating the same record over and over if multiple values are changed for the same record.

Do I need to use a combination of events?
1. RowsChanged - store an instance of the GridViewRow to a local variable
 then
2. RowValidated - commit row information to database?

Is there a more direct way to do what I need to do?

Thanks,

Morgan


Svett
Telerik team
 answered on 10 Jun 2011
5 answers
302 views
Hello,

Sorry for the long subject line; I wasn't sure how else to phrase it.

First of all, here are my system details:  I am using RadControls for WinForms Q1 2009 in C# (I know that it's old, but that's what I'm stuck using for now).  I am using Visual Studio 2008 SP1 and this project is using the .NET Framework 3.5.  I have some experience with the ASP.NET and Winforms RadControls, but I am by no means an expert.

This project is using a main RadRibbonForm as an MDI parent.  It then has several child MDI RadForms which all inherit from a base RadForm.  Because I am using a RadRibbonForm, I don't have a menu strip defined.  The problem that I'm having is that I have multiple rows of minimize, maximize and close buttons appearing (Please see the screenshots).  When I first open up the application, I don't have any of the MDI children visible.  However, when I open up one of the MDI children, it opens unmaximized and I can see its title bar.  When I maximize the MDI child, I see what is shown in the screenshot ribbonformmdi01.jpg.  When I unmaximize or minimize the MDI child, I see what is shown in the screenshot ribbonformmdi02.jpg.  Finally, when I close the MDI child, I see what is shown in the screenshot ribbonformmdi03.jpg. 

I thought that by setting the the base child MDI RadForm's window state property to "Maximized" in design time, that this would solve the problem.  The screenshot ribbonformmdi04.jpg shows what I see when I open the MDI child.  It opens maximized, but I have no way of minimizing or closing the child MDI form. 

I know that I must be overlooking something.  Can anybody offer any help, please?  What am I missing?  I have been looking all over the forums but the only thing that I've been able to find is what to do if you have a RadMenu and you want to merge the child's RadMenu with the parent's RadMenu.  This obviously doesn't apply.  I have also tried without any success to set various properties in the child RadForms such as the TitleBar's visibility property but that hasn't done the trick either.  Thanks in advance for any help that you can give.

Regards,
John
Boryana
Telerik team
 answered on 10 Jun 2011
1 answer
71 views
Hello All,

I have been working with a RadGridView, and I was wondering about a few things.

One, I have a gridview that is populated when an item from a list is selected and a button is checked. When I have BestFitColumns(), the column headers are not present. If I close the table and re-open it, they then appear. Ideas (this might be a bug that was fixed in SP1--I am running the version prior to SP1)?

Second, I have the horizontal scroll bar property set in one of my gridviews, and it never appears. I have tried manually sizing the columns, so that the columns would be bigger than the window and force a scroll bar; however, this isn't working (in fact, in this particular table, it appears that the size of the columns is being controlled by something else). Ideas?

Thanks,
Jack
Telerik team
 answered on 10 Jun 2011
1 answer
161 views
Hi,
I have a problem in my application: I have a radtextbox multiline (not ReadOnly) where some text is loaded; this text contains some words within single quotes (').
When I load the whole text of my application in this textbox, the text is correctly visualized, but if I try to modify the text, the control update the content deleting completing the words within quotes and it performs actions not requested.

I think this is due to the texts within quotes.
 Is there a way to avoid this behaviour and to manage the text and the words within the quotes as pure text, avoiding the radtextbox text/character events?
I also need to manage text read from  an xml document with a xmlnode object and copied to a string: the text contains words within quotes as before.
The text of the xml document is correctly read in the xmlnode object, but the string variable doen' t store the part of text after the first single quotes character and the character itself.
Is a different object more suitable for my purpose? In my application I must use a string variable to store the xml text.

Thanks in advance
Jack
Telerik team
 answered on 10 Jun 2011
1 answer
98 views
Hi,
we are developing with Telerik Winforms controls Q3 2007.
We are trying to get the event inside GridviewComboboxColumn when selected index or selected value is changed, but we can't get this event.
We guess it must be so easy that we think it must be in front of us, but we can't see it... it's we drive us crazy.

Please, someone can help us.

Thanks in advance

Stefan
Telerik team
 answered on 10 Jun 2011
Narrow your results
Selected tags
Tags
GridView
General Discussions
Scheduler and Reminder
Treeview
Dock
RibbonBar
Themes and Visual Style Builder
ChartView
Calendar, DateTimePicker, TimePicker and Clock
DropDownList
Buttons, RadioButton, CheckBox, etc
ListView
ComboBox and ListBox (obsolete as of Q2 2010)
Chart (obsolete as of Q1 2013)
Form
PageView
MultiColumn ComboBox
TextBox
RichTextEditor
PropertyGrid
Menu
RichTextBox (obsolete as of Q3 2014 SP1)
Panelbar (obsolete as of Q2 2010)
PivotGrid and PivotFieldList
Tabstrip (obsolete as of Q2 2010)
MaskedEditBox
CommandBar
PdfViewer and PdfViewerNavigator
ListControl
Carousel
Diagram, DiagramRibbonBar, DiagramToolBox
GanttView
Panorama
New Product Suggestions
Toolstrip (obsolete as of Q3 2010)
VirtualGrid
AutoCompleteBox
Label
Spreadsheet
ContextMenu
Panel
Visual Studio Extensions
TitleBar
Documentation
SplitContainer
Map
DesktopAlert
ProgressBar
CheckedDropDownList
TrackBar
MessageBox
Rotator
SpinEditor
StatusStrip
CheckedListBox
LayoutControl
SyntaxEditor
Wizard
ShapedForm
TextBoxControl
Conversational UI, Chat
DateTimePicker
CollapsiblePanel
TabbedForm
CAB Enabling Kit
GroupBox
DataEntry
ScrollablePanel
ScrollBar
WaitingBar
ImageEditor
Tools - VSB, Control Spy, Shape Editor
BrowseEditor
DataFilter
ColorDialog
FileDialogs
Gauges (RadialGauge, LinearGauge, BulletGraph)
ApplicationMenu
RangeSelector
CardView
WebCam
BindingNavigator
PopupEditor
RibbonForm
Styling
TaskBoard
Barcode
Callout
ColorBox
PictureBox
FilterView
Accessibility
VirtualKeyboard
NavigationView
DataLayout
ToastNotificationManager
ValidationProvider
CalculatorDropDown
Localization
TimePicker
ButtonTextBox
FontDropDownList
Licensing
BarcodeView
BreadCrumb
Security
LocalizationProvider
Dictionary
Overlay
Flyout
Separator
SparkLine
TreeMap
StepProgressBar
SplashScreen
ToolbarForm
NotifyIcon
DateOnlyPicker
Rating
TimeSpanPicker
Calculator
OfficeNavigationBar
TaskbarButton
HeatMap
SlideView
PipsPager
AIPrompt
TaskDialog
TimeOnlyPicker
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?