mvc Field.SetValue()

mvc Field.SetValue()

montoyammontoyam Posts: 441Questions: 106Answers: 5

I know I can use render on the client side, but is there a way in the controller to use a function to return a value for a read only field.

                    .Field(new Field("Units")

                            if (Fund == "All")  {
                             return this
                            } else { return that }

This question has an accepted answers - jump to answer


  • allanallan Posts: 54,171Questions: 1Answers: 8,455 Site admin
    Answer ✓

    Yes - have a GetValue as a simple string and then pass it through a get formatter to do the dynamic calculation (since that can be given as an anonymous function).

    Also, you'd want to use GetValue() in this case, not a set. Get in this context is reading from the server to the client (browser), while Set is what is set to the database.


    new Field("Units")
      .GetFormatter( (val, data) => {
        // ... some logic
      } )

    will hopefully do it for you.


Sign In or Register to comment.