Get current model iteration inside "X.ColumnFor"

  1. #1

    Get current model iteration inside "X.ColumnFor"

    Hi.

    I have this model: List<MyViewModel>:

    And i have this columnFor:


                 X.ColumnFor(Model, m => m.Value)
                     .ToBuilder<Column.Builder>()
                     .Text("Valor")    //** LITERAL
                     .Flex(1)
                     .Editor(
                         Html.X().TextField().AllowBlank(false).Regex(@"/^([^/*:\""|<>\\]+)+$/")   // <--- THIS
                ),
    i want set REGEX like this way:

    Html.X().TextField().AllowBlank(false).Regex(m.MyRegex)
    Where i put "m.MyRegex" in place of the string directly, code does not work. There is anyway for to that ?

    thanks in advance
  2. #2
    Hello @queriable! Welcome to Ext.NET forums!

    The editor in a column row is not a different editor field for each row, but a same editor moved throughout the grid.

    So short answer is that this is not possible like the way you are trying.

    I'm not sure why you need a different regexp depending on the row you are using but, if all you need is a single regexp for all rows of that given column, what you can do is have your model with a list of entries (that will be your rows' data).

    Something like having a @Model.Data and use it on your ColumnFor (e.g. X.ColumnFor(Model.Data, m => m.Value)) and then have, outside of Data, the RegExp value, being accessible via Model.RegExp. Possibly a different regexp per column then.

    That is, if you need a same regexp for each column, regardless of the row being edited.

    If the regexp is dependant on some data of the current row, you have to store the regexp in the javascript-side model (which you bind with the grid store) and then update the regexp value on the field when the field is moved to the cell being edited. For example, using the BeforeEdit event.

    Well, if that's too confusing, we could make a better deal if you provide us a simplified and fully runnable example with your use case so we can work over it.

    If in doubt on how to come up with a simple runnable example, please refer to these posts:
    - Tips for creating simplified code samples
    - Forum Guidelines For Posting New Topics
    - More information required

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    If the regexp is dependant on some data of the current row, you have to store the regexp in the javascript-side model (which you bind with the grid store) and then update the regexp value on the field when the field is moved to the cell being edited. For example, using the BeforeEdit event.
    Exactly, in a same column i want a different regex for a different ROW(In my list of objects, regex is a property of every object).

    BeforeEdit could be a solution for my problem. I would thank a example where properties of every row is edited with "BeforeEdit" event.

    Thanks a lot!
  4. #4
    Hello @queriable!

    We can advice you on a test case you provide but, unfortunately, we don't have an example to show you up front. So if you don't mind providing a test case that would suit your needs and correctly represent your scenario, we'll be able to help you. Please refer to the links on my previous post for building up a good test case.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 14
    Last Post: Apr 27, 2016, 12:49 AM
  2. Replies: 3
    Last Post: Jan 28, 2016, 6:13 PM
  3. Replies: 0
    Last Post: Nov 15, 2013, 9:32 AM
  4. Replies: 1
    Last Post: Sep 11, 2013, 5:39 PM
  5. Replies: 5
    Last Post: May 02, 2012, 5:37 PM

Posting Permissions