Format.DateFormat does not compile, what am I missing?

Format.DateFormat does not compile, what am I missing?

Matt BeckerMatt Becker Posts: 3Questions: 1Answers: 0

Hello, I'm new to Editor. I'm working with c#, .NET, MVC, and MS SQL. I used Generator to create a time field (no date). In the controller code, Generator created:

            var response = new Editor(db, "test", "id")
                .Model<TestModel>()
                .Field(new Field("time1")
                        .Validator(Validation.DateFormat("HH:mm"))
                        .GetFormatter(Format.DateFormat("HH:mm:ss", "HH:mm"))
                        .SetFormatter(Format.DateFormat("HH:mm", "HH:mm:ss"))
                )

But it doesn't compile with the error: 'Format' does not contain a definition for DateFormat. I have a reference to the DataTables.dll, so everything else complies. And it works if I click Run Now from Generator. What am I missing?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,961Questions: 1Answers: 10,759 Site admin

    Could you try using DataTables.Format.DateFormat please? I wonder if there might be a conflict with another class happening?

    Thanks,
    Allan

  • Matt BeckerMatt Becker Posts: 3Questions: 1Answers: 0

    HI Allan,

    Sorry for the delay, I got a little sidetracked.

    I tried changing the code to:

            .GetFormatter(DataTables.Format.DateFormat("HH:mm:ss", "HH:mm"))
            .SetFormatter(DataTables.Format.DateFormat("HH:mm", "HH:mm:ss"))
    

    But autocomplete couldn't find DateFormat after DataTables.Format. Autocomplete had other methods, like DateSqlToFormat for example.

    I have v1.5.6 of DataTables.dll. That's what was included when I downloaded Editor.

    Thanks!

  • allanallan Posts: 64,961Questions: 1Answers: 10,759 Site admin
    Answer ✓

    Apologies, it is DateTime rather than DateFormat. So:

    .GetFormatter(DataTables.Format.DateTime("HH:mm:ss", "HH:mm"))
    .SetFormatter(DataTables.Format.DateTime("HH:mm", "HH:mm:ss"))
    

    Allan

  • Matt BeckerMatt Becker Posts: 3Questions: 1Answers: 0

    That compiled, and it gets me a lot closer to understanding to it all works. Thanks!

This discussion has been closed.