Telerik Forums
UI for WPF Forum
1 answer
28 views

I have a RadBusyIndicator and inside it I have several other controls; the structure is bit complex and there are several DB operations are performed in that and while performing that DB operations we are setting IsBusy property of RadBusyIndicator as per progress to true and false. But after invoking this property keyboard focus is shifted to the main window which is not the correct behavior. 

I want my focus on the current control from where I am calling some commands, and it is doing some DB operations.

I have gone through the below solution, but it is not much helpful in my case because the structure of my code is bit complex and I don't want BusyIndication invoked every five seconds as mentioned in this link - "how to restore the focus"

Any help regarding this is much appreciated.

Dimitar
Telerik team
 answered on 15 Dec 2023
1 answer
34 views

Hi,

I have a problem, that I cannot solve. I have a Grid View (see attachment) based on a SQL Table. Now have replaced some colums with a comboBox.

The comboBoxes receive the data from the following table.

| ID  |  Country |  Plant  |  Area  |  Machine |
------------------------------------------------
|  1  |   DE     |   MUC   |  BA    |   A      |
|  2  |   DE     |   MUC   |  BA    |   A      |
|  3  |   AT     |   VIE     |  BE    |    1      |
|  4  |   AT     |   VIE     |  BE    |    2      |

F.e. The column "Country" in my GridView has as ItemSource a grouping of the column Country. Now I want to update the comboBox "Plant" depending on the value of the ComboBox "Country" meaning that when "DE" is chosen, it should only show "MUC" as a possible entry. How can I do that? Here is my code.

Thanks.


 public partial class MainWindow : Window
 {
     private SqlConnection connection;
     private string dbName = string.Empty;
     
     public MainWindow()
     {
         InitializeComponent();
         LoadData();
     }

     private void LoadData()
     {

         try
         {
             string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
             using (SqlConnection connection = new SqlConnection(connectionString))
             {
                 connection.Open();
                 string query = "SELECT * FROM dbo.MachineAreas";
                 SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
                 DataTable dataTable = new DataTable();
                 adapter.Fill(dataTable);

                 gridMachineAreas.ItemsSource = dataTable.DefaultView;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message);
         }
     }

     private void GridMachineAreas_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
     {            

         switch ((e.Column as GridViewDataColumn).DataMemberBinding.Path.Path)
         {
             case "ID":
                 var newColumn1 = new GridViewDataColumn();
                 newColumn1.CopyPropertiesFrom(e.Column);
                 newColumn1.Header = "ID";
                 newColumn1.Width = 60;
                 e.Column = newColumn1;
                 break;

             case "Country":
                 var newColumn2 = new GridViewComboBoxColumn();
                 newColumn2.CopyPropertiesFrom(e.Column);
                 newColumn2.Header = "Country";
                 newColumn2.Width = 60;
                 newColumn2.UniqueName = "Country";
                 newColumn2.IsComboBoxEditable = false;
                 newColumn2.ItemsSource = MakeCountryCollection();                    
                 
                 e.Column = newColumn2;
                 break;
             case "Plant":
                 var newColumn3 = new GridViewComboBoxColumn();
                 newColumn3.CopyPropertiesFrom(e.Column);
                 newColumn3.Header = "Plant";
                 newColumn3.Width = 60;                    
                 e.Column = newColumn3;
                 break;
             case "Area":
                 var newColumn4 = new GridViewComboBoxColumn();
                 newColumn4.CopyPropertiesFrom(e.Column);
                 newColumn4.Header = "Area";
                 newColumn4.Width = 60;
                 e.Column = newColumn4;
                 break;
             case "Machine":
                 var newColumn5 = new GridViewComboBoxColumn();
                 newColumn5.CopyPropertiesFrom(e.Column);
                 newColumn5.Header = "Machine";
                 newColumn5.Width = 60;
                 e.Column = newColumn5;
                 break;
         }

     }

     private List<string> MakeCountryCollection()
     {
         List<string> countryCollection = new List<string>();
         string query = "SELECT Country FROM dbo.MachineAreas Group By Country";
         
         try
         {
             string connectionString = "Data Source=localhost;Initial Catalog=Test_DB;Integrated Security=True";
             using (SqlConnection connection = new SqlConnection(connectionString))
             {
                 connection.Open();


                 using (SqlCommand command = new SqlCommand(query, connection))
                 {
                     using (SqlDataReader reader = command.ExecuteReader())
                     {


                         while (reader.Read())
                         {
                             string value = reader.GetString(0);
                             countryCollection.Add(value);
                         }
                         
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: " + ex.Message);
         }
         return countryCollection;
     }
 }


Dimitar
Telerik team
 answered on 12 Dec 2023
1 answer
38 views

I just started WPF trial. I need help though. I am going to have large grids (10Ks rows x 100 columns) with frequent update of certain cells (100s upd/sec).

I am not sure I can use your virtual grid - need more time to understand what are the drawbacks.

So I use RadGridView (see below - this is not final version - just a first try - what I quickly read in your article on making grid more performant).

Columns are made in C# and bound to dictionaries using string key like: `Binding("f[NAME].Value")` where `Value` is of type object (this is best I can do - dont ask - a requirement i cannot circumvent)

Now, what is my question here - when I load grid with data initially - most of the values in cells arent available yet. I am asked to display something to highlight that state. Also sometime some rows might get unavailable in the middle of use. But bottom line - these "unavailable" cues are going to live may be 0.5% of the grid life-time..

I dont want to write cell templates that will lengthen the visual tree and  make grid slow for something that i need for very short period of time.. 

Is there a way to optimise it?

One theory - add something to the visual tree in the beginning and then take it away.. (like walking visual tree manually and inserting a semi-transparent red border or something like that? or changing template of rows, that have became available, into lightweight ones). Concern here - binding might get broken after manipulation with visual tree..

Or I can set all the values to a string like "N/A". However concern here is that what happens with the columns types in this case? Wont this screw the grid ability to sort/filter - because columns will pick up initial "string" type and later, when I change it to real data, (can be date/number/etc) - they break down completely.

Can I set columns type explicitely after N/A disappeared (however not clear - N/A might stay in some rows longer than in others and few could be N/A for lot longer)...

Any trick you can recommend?

NOTE: the same question applies on tree view (even more so)

 

<telerik:RadGridView x:Name="dg" ItemsSource="{Binding data}" ValidatesOnDataErrors="InEditMode" IsPropertyChangedAggregationEnabled="False" GroupRenderMode="Flat" ShowGroupPanel="False"AutoGenerateColumns="False"CanUserFreezeColumns="False"RowIndicatorVisibility="Collapsed"CanUserResizeColumns="False">

Martin Ivanov
Telerik team
 answered on 08 Dec 2023
1 answer
42 views
Hello Telerik Team,
Please let me know how to avoid the horizontal white lines in the RadGridView. (Refer the attachment please)
If I do a vertical scroll, the horizontal white lines disappear for some rows and appear for some rows.
Behaves weirdly.
Awaiting for the solution.

Thanks and Regards,
Muhammad Azhar Shah
Martin Ivanov
Telerik team
 answered on 06 Dec 2023
1 answer
26 views

Hi,

I am trying to add new record into Details in Master Details RadGridView (Based on Telerik Demos/GridView/Editing/Entity Framework CRUD). I added option to add new detail record into master, in row details grid view new row with message "Click here to ad new item" appeared. After clicking on message an filling data in GridViewAddingNewEventArgs, I see new record in the details, but when I try to save it with dbContext.SaveChanges(), I've got message in output window about SQL update statement instead of insert (I always got the EntityFrameworkCore.DBUpdateConcurrencyException). 

 

Ľubomír
Top achievements
Rank 1
Iron
 updated answer on 04 Dec 2023
1 answer
29 views

Hey i dont want to use the integrated version of the Searchpanel because my design has it a different possition than direktly above it.

So i want to use  <telerik:GridViewSearchPanel   /> but i dont know how to bind it to the RadGridView.

Thanks

Dominik

 


Martin Ivanov
Telerik team
 answered on 24 Nov 2023
1 answer
33 views
Hi Telerik,
I have 30+ columns in my RadGridView and using CellTemplate and CellEditTemplate for most of the columns.
I want to reorder a column in runtime. When I click and drag a column header to extreme right or left, the horizontal scroll bar in the RadGridView is not scrolling automatically.
Is it a default behavior? Or do we have any property to enable this feature.
Please let us know ASAP.

Thank you.

Regards,
Muhammad Azhar Shah.
Martin Ivanov
Telerik team
 answered on 22 Nov 2023
1 answer
56 views

Hello,

 

we have a RadGridView which we define in a .xaml file. To this grid we add a few dynamic columns via a Behavior. Our Problem now is, that the columns we defined in the .xaml-file can be filtered normaly, but the dynamicaly added columns are missing the filter icon in the column header. We tried adding a new Instance of the FilterControl which shows the filter icon, but the FilterControl does not do anything and is missing the Search Textboxes.

 

Can you guide us advice on what we need to do to get the filter working for those columns?

 

Here is the code of the Behavior we use to add the dynamic columns:

 


public class RadGridViewAddCustomFieldDefinitionColumnsBehavior : RadGridViewAddFieldDefinitionColumnsBehavior<CustomFieldDefinition>
{
    protected override void AddFieldsColumns(
        IEnumerable<CustomFieldDefinition> fieldDefinitions,
        GridViewDataControl radGridView,
        RadGridViewAddFieldDefinitionColumnsBehavior<CustomFieldDefinition> radGridViewAddFieldColumnsBehavior)
    {
        var corporationIDToNameConverter = new CorporationIDToNameConverter();
        var contactIDToNameConverter = new ContactIDToNameConverter();

        foreach (var customFieldDefinition in fieldDefinitions)
        {
            var column = new GridViewDataColumn
                         {
                             Header = customFieldDefinition.PropertyName,
                             UniqueName = customFieldDefinition.PropertyName,
                             DataMemberBinding = new Binding("CustomFields")
                                                 {
                                                     Converter = new ValueConverterChain
                                                                 {
                                                                     optionalDictionaryValueConverter,
                                                                 },
                                                     ConverterParameter = new ValueConverterChainParameters
                                                                          {
                                                                              customFieldDefinition.ID,
                                                                          },
                                                 },
                         };

            switch (customFieldDefinition.FieldType)
            {
                case FieldType.Corporation:
                    SetColumnValueConverter(column, customFieldDefinition, corporationIDToNameConverter);
                    break;
                case FieldType.Contact:
                    SetColumnValueConverter(column, customFieldDefinition, contactIDToNameConverter);
                    break;
            }

            CurrentFieldDefinitionColumns.Add(column);
            radGridView.Columns.Add(column);
        }
    }

    protected override void SetColumnValueConverter(
        GridViewDataColumn column,
        CustomFieldDefinition fieldDefinition,
        IValueConverter valueConverter)
    {
        var converterChain = (ValueConverterChain)column.DataMemberBinding.Converter;
        var valueConverterChainParameters = (ValueConverterChainParameters)column.DataMemberBinding.ConverterParameter;

        converterChain.Add(valueConverter);
        valueConverterChainParameters.Add(fieldDefinition.Values);
    }
}

 

Kind regards

 

Benny

Martin Ivanov
Telerik team
 answered on 13 Nov 2023
1 answer
31 views

Hello,
please I need help to display the data of this type List<List<string>> in the component RadGridView.
Attached is a work in progress that I've started and I'm stuck.

Thanks for your help 

Dinko
Telerik team
 answered on 10 Nov 2023
2 answers
29 views

I have the following code:

<telerik:GridViewDataColumn DataMemberBinding="{Binding CreatedBy.Name}" Header="Name"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding EventObject.TextData}" Header="User Text"/>

public UserType CreatedBy { get; set; }

public object EventObject { get; set; }

in another class:

public string TextData { get; set; }

 

In the first column, there is a filter icon, and it filters correctly. However, in the second column, there is no filter icon. Could you explain why this might be and how to resolve the issue?

 

Ohad
Top achievements
Rank 3
Bronze
Iron
Iron
 answered on 09 Nov 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?