How to get Regular Expression in IgGrid cell (Infragistics)?

后端 未结 1 478
无人及你
无人及你 2021-01-22 10:55

how can i have a regular expression on a igTextEditor in igGrid Updating?

i tried to use validate option but it didn\'t worked.

   $(\"#schedulerTable\")         


        
相关标签:
1条回答
  • 2021-01-22 11:19

    The lack of validation is because the validatorOptions belong to the editorOptions (as those get passed down to whatever editor you choose as provider). The validation: true only gets some defaults, which really won't do much for a text field besides the required.

    And then the RegExp option (which is for an email in the snippet above as far as I can tell) has been pattern since 15.2 :) So in the end for that time column you can try:

    //...
        editorOptions: {
         validatorOptions: {
           pattern: /^\d{1,2}\:\d{2}$/,
           onblur: true,
           onchange: true
         },
        },
    //..
    

    Here's an updated codepen: https://codepen.io/anon/pen/YrgYxj

    Edit: Or if you want to set the error message:

    //...
        editorOptions: {
         validatorOptions: {
           pattern: {
            expression: /^\d{1,2}\:\d{2}$/,
            errorMessage: "Time should match a pattern like 00:00"
           },
           onblur: true,
           onchange: true
         },
        },
    //..
    

    Depending on your goals you could also use a Mask Editor or a Date Editor as provider. Also the obligatory docs link: https://www.igniteui.com/help/iggrid-updating

    P.S. Bind to an empty array to avoid the error for that first row that has no values and more importantly primary key.

    0 讨论(0)
提交回复
热议问题