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

Refreshing RadWindow with the page

4 Answers 68 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Srikrishna
Top achievements
Rank 1
Srikrishna asked on 15 Jun 2012, 02:23 PM

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

4 Answers, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 18 Jun 2012, 10:57 PM
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

0
Srikrishna
Top achievements
Rank 1
answered on 19 Jun 2012, 05:51 AM

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.


0
Lancelot
Top achievements
Rank 1
answered on 19 Jun 2012, 08:51 PM
   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
0
Srikrishna
Top achievements
Rank 1
answered on 20 Jun 2012, 11:30 AM

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

Tags
Window
Asked by
Srikrishna
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Srikrishna
Top achievements
Rank 1
Share this question
or