This is a migrated thread and some comments may be shown as answers.

Add new row on top of the radgridview and popup

3 Answers 277 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jagan k
Top achievements
Rank 1
Jagan k asked on 29 Nov 2010, 09:25 AM
i need 2 clarification

1.


i need to give notification using popup window instead of alert. is there any control to implement popup.

2.

i am having a Business Object Named Customer. i am binding the customer collection to RadGridView. i need to add the new row on top of the gridview. i have given the code

<Grid>
       <telerik:RadGridView AutoGenerateColumns="False" EditTriggers="F2" HorizontalAlignment="Left" Name="rgrdCustomer" RowIndicatorVisibility="Visible" VerticalAlignment="Top" AddingNewDataItem="rgrdCustomer_AddingNewDataItem" Deleting="rgrdCustomer_Deleting" RowEditEnded="rgrdCustomer_RowEditEnded" RowValidating="rgrdCustomer_RowValidating" ActionOnLostFocus="CancelEdit">
           <telerik:RadGridView.Columns>
               <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerID}" Header="ID" IsReadOnly="True" Width="50" IsFilterable="False" IsGroupable="False" />
               <telerik:GridViewDataColumn DataMemberBinding="{Binding CustomerName}" Header="CustomerName*" Width="250" IsFilterable="False" IsGroupable="False" />
               <telerik:GridViewDataColumn DataMemberBinding="{Binding OpeningBalance}" Header="OpeningBalance" DataFormatString="{} {0:##,##,##0.00}" Width="100" TextAlignment="Right" IsResizable="False" IsFilterable="False" IsGroupable="False" />
               <telerik:GridViewDataColumn DataMemberBinding="{Binding ContactNumber}" Header="ContactNumber" Width="100" IsResizable="False" IsFilterable="False" IsGroupable="False" />
 
           </telerik:RadGridView.Columns>
       </telerik:RadGridView>
   </Grid>

class CustomerBO
   {
 
       #region Fields
               
       private int _CustomerID;
       private string _CustomerName;
       private decimal _OpeningBalance;
       private string _ContactNumber;
 
       #endregion
 
       #region Properties
 
       public int CustomerID
       {
           get { return _CustomerID; }
           set { _CustomerID = value; }
       }       
 
       public string CustomerName
       {
           get { return _CustomerName; }
           set { _CustomerName = value; }
       }       
 
       public decimal OpeningBalance
       {
           get { return _OpeningBalance; }
           set { _OpeningBalance = value; }
       }
 
 
       public string ContactNumber
       {
           get { return _ContactNumber; }
           set { _ContactNumber = value; }
       }
 
       #endregion
 
   }

public partial class CustomerView : UserControl
 {
     public CustomerView()
     {
         InitializeComponent();
     }
 
     private void rgrdCustomer_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
     {
         e.NewObject = new CustomerBO();
     }
 
     private void rgrdCustomer_Deleting(object sender, Telerik.Windows.Controls.GridViewDeletingEventArgs e)
     {
         CustomerDAL customerdata = new CustomerDAL();
 
         if (e.Items.Count() != 1)
         {
             Notification.ErrorMessage("More than one Customer Selected");
         }
 
         else
         {
             foreach (CustomerBO customer in e.Items)
             {
                 customerdata.Delete(customer.CustomerID);
                 Notification.InformationMessage("Deleted Sucessfully");
             }
         }
     }
 
     private void rgrdCustomer_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
     {
         if (e.EditAction == GridViewEditAction.Cancel)
         {
             return;
         }
 
         try
         {
             if (e.EditOperationType == GridViewEditOperationType.Insert)
             {
                 CustomerDAL customerdata = new CustomerDAL();
                 CustomerBO customerentity = (CustomerBO)e.NewData;
                 customerdata.Insert(customerentity);
                 this.LoadData();
                 Notification.InformationMessage("Added Successfully");
             }
 
             if (e.EditOperationType == GridViewEditOperationType.Edit)
             {
                 CustomerDAL customerdata = new CustomerDAL();
                 customerdata.Update((CustomerBO)e.NewData);
                 Notification.InformationMessage("Updated Successfully");
             }
             this.LoadData();
         }
         catch (Exception ex)
         {
             Notification.ErrorMessage(ex.Message);
         }
     }
 
     private void rgrdCustomer_RowValidating(object sender, Telerik.Windows.Controls.GridViewRowValidatingEventArgs e)
     {
 
         CustomerBO customer = e.Row.DataContext as CustomerBO;
 
         if (String.IsNullOrEmpty(customer.CustomerName) || customer.CustomerName.Length > 50)
         {
             RowValidation.Validate("CustomerName", "Fill the Customer Name", e);
         }
 
     }
 
     private void UserControl_Loaded(object sender, RoutedEventArgs e)
     {
         this.LoadData();
         this.rgrdCustomer.Focus();
     }
 
     private void LoadData()
     {
         CustomerDAL customerdata = new CustomerDAL();
         this.rgrdCustomer.ItemsSource = customerdata.FetchAll();
     }
 
      
 }

3 Answers, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 29 Nov 2010, 01:30 PM
Hello Jagan,


Please find my answers in this order:

1. Please check our demos for RadWindow for WPF.

2.You can change the position of GridViewNewRow within RadGridView's template. At the attached example you can see how to show GridViewNewRow above the GridViewHeaderRow and a comment that describes how you can easily change its position relatively to the GridViewGroupPanel.



Please see the attached example and let me know if you need any further assistance.


Sincerely yours,
Vanya Pavlova
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Adiel
Top achievements
Rank 1
answered on 15 Aug 2012, 09:28 AM
Hi

I tried your sample and it helped us a lot.

There is some problem with the vertical scrollbar. It disappears and come back when we play with the size of the screen (and we make the horizontal scrollbar to appear!)

Have you heard about this bug?

Thank you 

Meir
0
Dimitrina
Telerik team
answered on 15 Aug 2012, 04:37 PM
Hi,

 This is quite an old thread. May I ask you to share mode details on what version do you use? Have you done the same implementation as suggested?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Jagan k
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Adiel
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or