DataTable Editor, How can I add extra field on server side.

DataTable Editor, How can I add extra field on server side.

tdx369tdx369 Posts: 5Questions: 1Answers: 0

With ASP.net Mvc, How can I add extra field on server side when user create a new record.
for example,user input name,number etc and commit data to server, I want add ip,createdatetime,userid, and other field when create a new record on server side

Replies

  • rf1234rf1234 Posts: 2,906Questions: 87Answers: 414

    you can use set formatters and fill those fields as you like. you simply define them in your editor instance and fill them accordingly.

    https://editor.datatables.net/manual/net/formatters

  • tdx369tdx369 Posts: 5Questions: 1Answers: 0

    I tried it. Like the example in staffcontroller.cs .

    .Field(new Field("age")
    .Validator(Validation.Numeric())
    .SetFormatter(Format.IfEmpty(89))
    )
    .Field(new Field("salary")
    .Validator(Validation.Numeric())
    .SetFormatter(Format.IfEmpty(76))
    )

    When create a new record ,the "salary" value 76 inserted to database,but the "age" 89 value didn't inserted to database. In database table ,"age" always is null.but "salary" is good.
    Why? How can I do?

  • rf1234rf1234 Posts: 2,906Questions: 87Answers: 414

    So something else is wrong. Any error messages? Can you post an example, please.

  • tdx369tdx369 Posts: 5Questions: 1Answers: 0

    The under method shall be taken! It worked, well done!

    editor.Field(
    new Field( "created" )
    .Set( Field.SetType.Create )
    .SetValue( date("yyyy-MM-dd") )
    );

    editor.Field(
    new Field( "updated" )
    .Set( Field.SetType.Edit )
    .SetValue( date("yyyy-MM-dd") )
    );

    rf1234 ,Thank your support!

This discussion has been closed.