Switch is not filling in all the data

Asked

Viewed 29 times

0

Hello, I have a Grid and I am making some data changes for display, explaining better, in my database I saved the data with only one value: "V", "A", "O", and I want to make changes for display, as shows the switch.

function criador_linhas(s, e) {
    if (s.rowType == "data") {
        switch (s.data.CatVen_Tipo) {
            case "V":
                s.data.CatVen_Tipo1 = "Venda Avulsa";
                break;
            case "A":
                s.data.CatVen_Tipo1 = "Ambos";
                break;
            case "O":
                s.data.CatVen_Tipo1 = "Orçamento/Projeto";
                break;
            default:
                s.data.CatVen_Tipo1 = "Erro";
                break;
        }
    }
}

My database:

inserir a descrição da imagem aqui

The problem is this, it fills some values, but others it leaves empty, as shown in the image:

inserir a descrição da imagem aqui

My Datagrid:

@(Html.DevExtreme().DataGrid()
                                            .ShowBorders(true)
                                            .Height(355)
                                            .Selection(s => s.Mode(SelectionMode.Single))
                                            .DataSource(Model, new string[] { "CatVen_Codigo" })
                                            .Columns(columns =>
                                            {
                                                columns.Add().DataField("CatVen_Codigo").Width(100).Caption("Código");
                                                columns.Add().DataField("CatVen_Descricao").Caption("Descrição");
                                                columns.Add().DataField("CatVen_Tipo1").Width(120).Caption("Tipo");
                                                columns.Add().DataField("CatVen_Ativo").Width(120).Caption("Situação");
                                            }).OnSelectionChanged("selection_changed")
                                            .Paging(p => p.PageSize(10))
                                            .FilterRow(f => f.Visible(true))
                                            .HeaderFilter(f => f.Visible(true))
                                            .OnRowPrepared("criador_linhas")
                                            .GroupPanel(p => p.Visible(true))
                                            .GroupPanel(p => p.EmptyPanelText("Arraste uma coluna até aqui para agrupar por essa coluna"))
                                            .NoDataText("Nada encontrado")
                                            .Grouping(g => g.AutoExpandAll(false))
                                            .RemoteOperations(true)
                                            .LoadPanel(loadPanel => loadPanel.Enabled(false))
                                            .Scrolling(scrolling => scrolling.Mode(GridScrollingMode.Infinite))
)
  • 1

    Make sure the field s.rowType is being filled in as data, or even withdraw the validation to test. It is also good to check in the browser console if you are not having any error, because if there is an error in the fill as for example an access to an invalid object will happen to break too.

  • Check by console.log or Alert if the information is coming in correctly, and if there are no spaces or other additional character types in the string.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.