How I can set the current value and name in the select using dojo?

293 Views Asked by At

I create a function with name and id of m Select :

function loadDataFiltrosTipoFunc(Memory) {
    var statusStoreMotivo = new Memory({
            data: [
                    { name: "Todos", id: 0 },
                    { name: "Cobrança", id: 1 },
                    { name: "Aniversariantes", id: 2 }
            ]
    });
    dijit.byId("pesqFuncMotivo").store = statusStoreMotivo;
    dijit.byId("pesqFuncMotivo").set("value", TODOS);
};

When call to create new register, show me the options in the form.

My Problem is when call the "Edit", I have the id save in the registry, but I can not set the value name and show the other options to change in the Edit.

I made this : (There are comments in the code with my question more detail)

function EditarMensagem(itensSelecionados) {
    try {
        // first i check if any iten is selected (ItensSelecionados)
        // If is ckeked and no has value show message ask to select only one
        // else, if is selected only one and has value continue
        if (!hasValue(itensSelecionados) || itensSelecionados.length == 0)
            caixaDialogo(DIALOGO_AVISO, 'Selecione um registro para Editar.', null);
        else if (itensSelecionados.length > 1)
            caixaDialogo(DIALOGO_ERRO, 'Selecione apenas um registro para Editar.', null);
        else {

            // Here i Check the value of the select and put the name
            // I don´t shure if is the best way
            if (itensSelecionados[0].motivo = 0) {
                var motivo = "Aniversariantes";
            }
            if (itensSelecionados[0].motivo = 1) {
                var motivo = "Cobrança";
            }

            // Here in 'tipoSmsCompor' is my Select.
            // I try put the var motivo, 
            // but don´t set the name, and don´t show the other options of the list
            // declared in the function loadDataFiltrosTipoFunc(Memory)
            // How I can set the current value and name in the select and the other option to the user can change?
            dijit.byId( 'tipoSmsCompor' ).attr( 'value', itensSelecionados[0].motivo);
            dijit.byId("dc_assunto").set("value", itensSelecionados[0].mensagem);
            dijit.byId("cad").show();
            IncluirAlterar(0, 'divAlterarMensagem', 'divIncluirMensagem', 'divExcluirMensagem', '', 'divCancelarMensagem', 'divClearMensagem');
        }

    } catch (e) {
        postGerarLog(e);
    }
}

How I can set the current value and name in the select and the other options to the user can change?

I want set the return value and show me the other option in the funcion loadDataFiltrosTipoFunc, but with the value returned .

Thanks all.

0

There are 0 best solutions below