Refreshing RadWindow with the page

5 posts, 0 answers
  1. Srikrishna
    Srikrishna avatar
    18 posts
    Member since:
    Apr 2012

    Posted 15 Jun 2012 Link to this post


    Hi All,

    I am using Telerik RadWindow in my application. In this i have to insert values entered by user into database and also display them through database at the same.

    I am inserting values, but the displayed values are not showing up unless closing it and again opening it.

    Can anyone plese help me with the refreshing of the RadWindow so that i can display the inserted values at the same time they are added.

     

    Thanks in Advance

  2. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 18 Jun 2012 Link to this post

    Hi Srikrishna,
     
    I would love to help you, but I need to ask a couple questions first.
    1. What control are you using in the RadWindows to enter data?
    2. Is the data in your application bound to a ViewModel?
    3. Where are you expecting this data to be displayed after the user enters it?

    If you could provide a screenshot of your application with the RadWindow opened with the data that is not being refreshed and an explaination of the image, this would be extremely helpful towards me solving your issue.

     I assume you have an entire UserControl inside the RadWindow. So, the UserControl you are using to display/enter the data should be the element doing the work. The RadWindow is essentially a placeholder to contain another control.

    Good Luck,
    Lancelot

  3. DevCraft banner
  4. Srikrishna
    Srikrishna avatar
    18 posts
    Member since:
    Apr 2012

    Posted 19 Jun 2012 Link to this post


    Hi Lancelot,

    Thanks for the reply.
    I attached a screenshot of the RadWindow i am using in my application.

    I have a RadGridView which consists of items with checkbox and a TreeView with four nodes. 
    when i check n number of items from grid and click add button, the items should be added to a TreeView which is in the same window. I am doing this by inserting the items of the grid into database table and i am displaying the items in TreeView by using select query of the same table.

    The values are inserting but are not displayed at the same time. when i close the RadWindow and open it again then i am able to see the inserted values. I need the values to be displayed as soon as the user clicks on add button.

    Also, can i know if i can use telerik Asp.net ajax controls in silverlight for this issue?

    Thanks.


  5. Lancelot
    Lancelot avatar
    251 posts
    Member since:
    Jul 2012

    Posted 19 Jun 2012 Link to this post

       Looking at your screenshot it appears you are using the RadGridView and a RadTreeView in the RadWindow. 

      Are you using an MVVM architecture for your datamodel? If not, that would solve your problem. You would load the data into your MainViewModel from the database and the list of users would be in an ObservableCollection. Even if you are not using MVVM, you can still use an ObservableCollection instead of a List<>, this would allow the RadControls to automatically update the View when it senses a change is made to a list.

      If you cannot do it that way, you could always add an "Update" TreeView method inside of the button click event when you click Remove or Add. This would update the chart manually upon each function, for instance you could reassign the ItemsSource.

    Mostly I suspect you may not have the IsLoadOnDemand property set to true. This link will bring you to the ADO.NET documentation for RadTreeView, notice how the example project uses a LoadOnDemand method.

    Good Luck,
    Lancelot
  6. Srikrishna
    Srikrishna avatar
    18 posts
    Member since:
    Apr 2012

    Posted 20 Jun 2012 Link to this post

    Thanks Lancelot.
    I am using ado.net entity model and wcf ria services for connecting to database. Below is my code behind to add a user into treeview and display them in the treeview.
    Please suggest me the best way to refresh the treeview and show the users whenever they are added.

    private void btnAdd_Click(object sender, RoutedEventArgs e)
           {
               RadComboBoxItem selectedItem = ComboBox_Role.SelectedItem as RadComboBoxItem;
               //TelGV_AddUser is the GridView for Users
               int i, selItemCountGV = this.TelGV_AddUser.SelectedItems.Count;
               string userName, tagName = selectedItem.Tag.ToString();
               switch (tagName)
               {
                   case "System Administrator":
                       for (i = 0; i < selItemCountGV; i++)
                       {
                           // BSS.Web.BSS_sp_GetAllUsers_Result is the stored procedure to get all users into GridView
                           userName = ((BSS.Web.BSS_sp_GetAllUsers_Result)(this.TelGV_AddUser.SelectedItems[i])).sgADUserName;
                           // TreeView_Admin is the Treeview Item (Administrator)
                           if (!TreeView_Admin.Items.Contains(userName))
                           {
                              // context is the instance of the domain service
                              // InsertUserByRole is the method for the store procedure to insert users into database
                               context.InsertUserByRole(userName, tagName);
                           }
                       }
                       break;
                   case "Land Administrator":
                       for (i = 0; i < selItemCountGV; i++)
                       {
                           userName = ((BSS.Web.BSS_sp_GetAllUsers_Result)(this.TelGV_AddUser.SelectedItems[i])).sgADUserName;
                           if (!TreeView_Land.Items.Contains(userName))
                           {
                               context.InsertUserByRole(userName, tagName);
                           }
                       }
                       break;
                   case "Sales - Burbank Homes":
                       for (i = 0; i < selItemCountGV; i++)
                       {
                           userName = ((BSS.Web.BSS_sp_GetAllUsers_Result)(this.TelGV_AddUser.SelectedItems[i])).sgADUserName;
     
                           if (!TreeView_SalesHome.Items.Contains(userName))
                           {
                               context.InsertUserByRole(userName, tagName);
                           }
                       }
                       break;
                   case "Sales - Burbank Invest":
                       for (i = 0; i < selItemCountGV; i++)
                       {
                           userName = ((BSS.Web.BSS_sp_GetAllUsers_Result)(this.TelGV_AddUser.SelectedItems[i])).sgADUserName;
     
                           if (!TreeView_SalesInvest.Items.Contains(userName))
                           {
                               context.InsertUserByRole(userName, tagName);
                           }
                       }
                       break;
     
                   default:
                       break;
               }
           }

    These are the Loaded events for the treeview items. 4 stored procedures are written to display the users in the treeview items.

    private void TreeView_Admin_Loaded(object sender, RoutedEventArgs e)
          {
              context.Load(context.DisplaySysAdminUsersQuery());
              TreeView_Admin.ItemsSource = context.BSS_sp_DisplayUserByRoleSysAdmin_Results;
          }
          private void TreeView_Land_Loaded(object sender, RoutedEventArgs e)
          {
              context.Load(context.DisplayLandAdminUsersQuery());
              TreeView_Land.ItemsSource = context.BSS_sp_DisplayUserByRoleLandAdmin_Results;
          }
     
          private void TreeView_SalesHome_Loaded(object sender, RoutedEventArgs e)
          {
              context.Load(context.DisplaySalesHomeUsersQuery());
              TreeView_SalesHome.ItemsSource = context.BSS_sp_DisplayUserByRoleSalesHome_Results;
          }
     
          private void TreeView_SalesInvest_Loaded(object sender, RoutedEventArgs e)
          {
              context.Load(context.DisplaySalesHomeInvestUsersQuery());
              TreeView_SalesInvest.ItemsSource = context.BSS_sp_DisplayUserByRoleSalesInvest_Results;
          }

Back to Top
DevCraft banner