Add new row on top of the radgridview and popup

4 posts, 1 answers
  1. Jagan k
    Jagan k avatar
    10 posts
    Member since:
    Feb 2010

    Posted 29 Nov 2010 Link to this post

    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();
         }
     
          
     }

  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Nov 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Meir Bezalel
    Meir Bezalel avatar
    9 posts
    Member since:
    Dec 2009

    Posted 15 Aug 2012 Link to this post

    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
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 15 Aug 2012 Link to this post

    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.

Back to Top