popup filter onKeypress

10 posts, 1 answers
  1. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 02 Nov 2018 Link to this post

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

    thanks

  2. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 02 Nov 2018 in reply to Andre Link to this post

    I found this but it doesn't work.

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

                dgvOrder.BeginEdit();

  3. Dimitar
    Admin
    Dimitar avatar
    2892 posts

    Posted 05 Nov 2018 Link to this post

    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.
  4. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 06 Nov 2018 in reply to Dimitar Link to this post

    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

  5. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 06 Nov 2018 Link to this post

    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.
  6. Dimitar
    Admin
    Dimitar avatar
    2892 posts

    Posted 06 Nov 2018 Link to this post

    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.
  7. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 06 Nov 2018 in reply to Dimitar Link to this post

    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.

  8. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 06 Nov 2018 Link to this post

    hi dimitar

    Is there any reason why this

    textBox.focus();

    isn't working?

  9. Answer
    Dimitar
    Admin
    Dimitar avatar
    2892 posts

    Posted 07 Nov 2018 Link to this post

    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.
  10. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 08 Nov 2018 in reply to Dimitar Link to this post

    hi dimitar

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

    regards,

    andre

Back to Top