Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
Numeric Keypad and Select All
posted

I have a grid with a qty and a description.   Currently, when I edit the cell it gives me the default keyboard.  

1.  I need to make this a number pad
2.  I need to automatically select the number automatically, so when he edits he overwrites the existing value

3.  Perform validation on the number as it is entered or when editing ends. 

  • 205
    Offline posted

    Also, this is a Xamarin.iOS app.

  • 40030
    Offline posted

    Hey, 

    Sorry for the delayed response. 

    Assuming you're using the IGGridViewDatsourceHelper and IGGridViewColumns, then you can take advantage of some of the grid's default editing capabilities: 

    We have a help topic on it that explains some of it; 

    http://www.infragistics.com/help/ios/iggridview-configuring-grid-data-entry

    There is also the IGGridVIewDatasourceHelperEditingDelegate you can hook up on your DSH:

    http://help.infragistics.com/ios/2016.2/igapi/Protocols/IGGridViewDataSourceHelperEditingDelegate.html

    To answer your questions: 

    1. Thats controlled on the UITextField: https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

    You could use the EditingDelegate to change the keyboard type, or create a custom column and display your own editor, and set the defaults you want.  (i beielve that the number pad keyboard is only for phones and not for iPads)

    2. You can use the editing delegate, and do the following: 

    http://stackoverflow.com/questions/19134405/uitextfield-highlight-all-text

    3. You can use the editing delegate to be notified when the cell is leaving edit mode. 

    Hope this helps, 

    -SteveZ

  • 205
    Offline posted

    I figured this out myself yesterday, and I thought i'd take the time to explain how to do this in a little more detail then we usually get on this forum.  

    1.  You need to create a new class as follows. Inherit from IGGridViewDatasourceHelperEditingDelegate
    public class SomeNewEditingDelegate : IGGridViewDataSourceHelperEditingDelegate

    2.  Inside this class you need to override the CellEnteringEditMode method as follows
    public override void CellEnteringEditMode(IGGridViewDataSourceHelper dsh, IGGridViewCell cell, Foundation.NSObject val, UIKit.UIView editor, IGGridViewColumnDefinition col)

    3.  Inside of the method in #2, add the code to do any validation or change the keyboard.  Should look something like this...
        txtQuantity = (UITextField)editor;
        txtQuantity.InputAccessoryView = qtyInputView;
        txtQuantity.PerformSelector(new Selector("selectAll"), null, 0.0f);
       //it is important to call the selector here because txtQuantity.SelectAll does not work

    4.  Now in your method where you bind to the grid (probably in your ViewController) 
         myGrid. EditingDelegate = new CullEditingDelegate(this);

    That's all there is to it.  You can now change the keyboard, select the number and validate the value as needed.