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

popup filter onKeypress

9 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 02 Nov 2018, 05:50 PM

how to open the filter popup, set the focus on the textbox, when loading the grid.

thanks

9 Answers, 1 is accepted

Sort by
0
Andre
Top achievements
Rank 1
answered on 02 Nov 2018, 07:14 PM

I found this but it doesn't work.

            dgvOrder.CurrentRow = dgvOrder.MasterView.TableFilteringRow;
            dgvOrder.CurrentColumn = dgvOrder.Columns[3];

            dgvOrder.BeginEdit();

0
Dimitar
Telerik team
answered on 05 Nov 2018, 07:53 AM
Hi Andre,

You can use the following code for this:
protected override void OnShown(EventArgs e)
{
    base.OnShown(e);
    var cell = radGridView1.TableElement.GetCellElement(radGridView1.MasterView.TableHeaderRow, radGridView1.Columns[2]) as GridHeaderCellElement;
    cell.FilterButton.PerformClick();
 
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Andre
Top achievements
Rank 1
answered on 06 Nov 2018, 07:11 AM

hi dimitar
thanks for the solution !
the call works as desired.

how can i set the focus on the search-textfield so that you can start directly with the input of the filtertext ?

regards

andre

0
Andre
Top achievements
Rank 1
answered on 06 Nov 2018, 07:33 AM
then i have another problem with the filter-textbox. at the first call you see only half of it. from the second call on you see the complete textbox.
0
Dimitar
Telerik team
answered on 06 Nov 2018, 11:32 AM
Hello Andre,

I could not find a good way for this. The only solution would be to click the textbox with code when the popup is opened:
private void RadGridView1_FilterPopupInitialized(object sender, Telerik.WinControls.UI.FilterPopupInitializedEventArgs e)
{
    var popup = e.FilterPopup as RadListFilterPopup;
    if (popup != null)
    {
        popup.PopupOpened += Popup_PopupOpened;
 
    }
}
 
private void Popup_PopupOpened(object sender, EventArgs args)
{
    var popup = sender as RadListFilterPopup;
    var textBox = popup.TextBoxMenuItem.HostedControl as RadTextBox;
 
    Cursor.Position = popup.Location;
    NativeMethods.PostMessage(new System.Runtime.InteropServices.HandleRef(popup, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONDOWN,0,0);
 
}

In addition, the textbox has correct size on my side. I have attached my test project. Could you please check it and let me know how it differs from your real setup? 

I am looking forward to your reply.
 
Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Andre
Top achievements
Rank 1
answered on 06 Nov 2018, 01:42 PM

hi dimitar

many thanks for the sample application.
the textbox has the right size in your example. however the click into the textbox doesn't seem to work. i still have to click into the textbox before writing anything.
the goal is to get an input possibility for filtering without using the mouse.

0
Andre
Top achievements
Rank 1
answered on 06 Nov 2018, 03:33 PM

hi dimitar

Is there any reason why this

textBox.focus();

isn't working?

0
Accepted
Dimitar
Telerik team
answered on 07 Nov 2018, 08:51 AM
Hi Andre,

The mistake is mine. You need to send a mouse up message as well. This way you will be able to directly type in the text box:
NativeMethods.PostMessage(new System.Runtime.InteropServices.HandleRef(textBox.TextBoxElement.TextBoxItem.TextBoxControl, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONDOWN,0,0);
NativeMethods.PostMessage(new System.Runtime.InteropServices.HandleRef(textBox.TextBoxElement.TextBoxItem.TextBoxControl, textBox.TextBoxElement.TextBoxItem.TextBoxControl.Handle), NativeMethods.WM_LBUTTONUP, 0, 0);

The cursor needs to be somewhere in the popup because otherwise the popup will be closed (the popup will receive the message as well). Just calling the Focus method would not work because the textbox is inside a popup which is a separate window. This method is inherited from the standard controls and we do not have control over this functionality.
 
Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Andre
Top achievements
Rank 1
answered on 08 Nov 2018, 07:11 AM

hi dimitar

exactly what it was. Works as desired.
thank you very much for the excellent support.

regards,

andre

Tags
GridView
Asked by
Andre
Top achievements
Rank 1
Answers by
Andre
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or