如何使用dojo在select中设置当前值和名称?

问题描述 投票:0回答:1

我创建一个名称和ID为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);
};

调用创建新注册时,请向我显示表单中的选项。

我的问题是调用"Edit"时,我将ID保存在注册表中,但是无法设置值名称并显示其他选项以在“编辑”中进行更改。

我做了这个:(代码中有我的问题的注释有更多详细信息)

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);
    }
}

如何在select中设置当前值和名称,并且可以更改用户的其他选项?

我想设置返回值并在funcion loadDataFiltrosTipoFunc中向我显示另一个选项,但返回值。

谢谢。

javascript drop-down-menu dojo dijit.form
1个回答
0
投票
设置值通过选择的设置方法直接起作用
© www.soinside.com 2019 - 2024. All rights reserved.