How to display a .NET bit value in Editor

How to display a .NET bit value in Editor

bjlapbjlap Posts: 29Questions: 11Answers: 1
edited September 2015 in Editor

Hi,
I am using Editor with a SQL database that has a table with a column of type 'bit'. It stores 0 or 1 and represents true or false. The .Net editor object does not retrieve it although I have specified the column in the model object. I tried types int, string, bool, but the column is ignored by the editor object when data is retrieved in the controller`(other columns of type date, string and int work fine. What am I missing?
Thanks,
Bert-Jan

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,822Questions: 1Answers: 10,129 Site admin

    Hi,

    Have you tried using the radio field type to display selectable options to the end user and columns.render to display a human readable representation of the data in the table?

    Allan

  • bjlapbjlap Posts: 29Questions: 11Answers: 1

    Thanks,
    finally got this to work. In the controller editor object I had to add :

     .Field(new Field("HoursEntry.Travel", typeof(bool)))
    

    I had expected it to work without specifically specifying the field, but that is not always the case..
    Bert-Jan

  • bjlapbjlap Posts: 29Questions: 11Answers: 1

    One more question:
    The radio button for updating works fine now but I haven't managed to get columns.render to work.

    I looked at some examples but is is unclear to me how I should use the columns.render option to display 'travel' instead of 'true' and 'work' instead of 'false' in the datatable.

    Can you point me to an example?
    Thanks,
    Bert-Jan

  • bjlapbjlap Posts: 29Questions: 11Answers: 1
    Answer ✓

    Never mind, got it to work: (In razor view with localized text)

                            "render": function ( data, type, full, meta ) {
                                if(data == true)
                                {
                                    return "@ProjectHours.App_GlobalResources.Text.Travel";
                                }
                                else
                                {
                                    return "@ProjectHours.App_GlobalResources.Text.Work";
                                }
                            }
    
This discussion has been closed.