Results 1 to 1 of 1

Thread: Problems with combobox intro GridPanel

  1. #1
    Member
    Join Date
    Jan 2012
    Posts
    37

    [CLOSED]Problems with combobox intro GridPanel

    Hi,
    i have one gridpanel with component columns and one editor column (DateField) with CellEditing plugin.

    Into the column model, i have two component column with a combobox each. These comboboxs are linked.
    On page load, the first combobox is loaded and the second combobox is loaded by the value of the first combobox.
    To fill the second combobox, i used a direct method to return a List to client side, by this list, i fill the second combobox with the js method: "combo.addItem(text,value)"

    The problem is: After edit the DateField editor, the second combobox values are cleaned. I don't know why this is occurring. The first combobox remains ok.

    The client side code:

    Code:
    <%@ Page Title="Agendamento" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
        CodeBehind="Agendamento.aspx.cs" Inherits="credenciada.nossatv.tv.br.Agendamento.Agendamento" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
        <script type="text/javascript">
    
    
    
            var cboGrupoMotivacao_OnSelectItem = function (el, record) {
                var selectedId = record[0].data.Id;
                var index = el.column.rowIndex;
                getMotivacao(selectedId, index);
            };
    
            var getMotivacao = function (id, index) {
                App.direct.GetMotivacao(id, {
                    success: function (motivacao) {
                        addItemsInCboMotivacao(motivacao, index);
                    }
                });
            };
    
            var addItemsInCboMotivacao = function (motivacao, index) {
    
                var combo = Ext.getCmp(App.ComponentColumnMotivacao.getComponent(index).id);
                combo.clear();
                combo.store.removeAll();
    
                for (var i = 0; i < motivacao.length; i++) {
    
                    var value = motivacao[i].ID_MOTIVACAO_AGENDAMENTO;
                    var text = motivacao[i].DS_MOTIVACAO_AGENDAMENTO;
                    combo.addItem(text, value);
                }
            };
    
            var validarEdicao = function (editor, e) {
                var rowIndex = e.rowIdx;
                if (e.column.disabled == true || getCboMotivacaoValue(rowIndex) != '1') {
                    return false;
                }
            };
    
            var getCboMotivacaoValue = function (index) {
                var combo = Ext.getCmp(App.ComponentColumnMotivacao.getComponent(index).id);
                return combo.getValue();
            }
    
            var cboMotivacao_Select = function (el) {
                if (el.getValue() == '1') {
                    App.ColumnDtAgendamento.setDisabled(false);
                    startEdit(el);
                }
                else {
                    App.ColumnDtAgendamento.setDisabled(true);
                }
    
            };
    
            var startEdit = function (el) {
    
                var grid = App.GridAgendamento;
                var rowIndex = el.column.rowIndex;
                grid.editingPlugin.startEditByPosition({ row: rowIndex, column: 4 })
            }
    
            var clearDateCell = function () {
            }    
    
        </script>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <ext:Viewport runat="server" Layout="BorderLayout">
            <Items>
                <ext:Panel runat="server" Title="Dados" Icon="Information" AutoDoLayout="true" Region="North"
                    BodyPadding="3" BodyStyle="height:auto">
                    <Items>
                        <ext:GridPanel runat="server" IDMode="Static" ID="GridAgendamento" Header="false"
                            Margin="7">
                            <Store>
                                <ext:Store ID="Store1" runat="server">
                                    <Model>
                                        <ext:Model ID="Model2" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="TipoTel" Mapping="TIPO_TELEFONE" />
                                                <ext:ModelField Name="Tel" Mapping="TELEFONE" />
                                                <ext:ModelField Name="DtAgendamento" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <Plugins>
                                <ext:CellEditing>
                                    <Listeners>
                                        <BeforeEdit Fn="validarEdicao">
                                        </BeforeEdit>
                                      
                                    </Listeners>
                                </ext:CellEditing>
                            </Plugins>
                            <SelectionModel>
                                <ext:CellSelectionModel ID="CellSelectionModel1" runat="server" />
                            </SelectionModel>
                            <ColumnModel>
                                <Columns>
                                    <ext:Column ID="Column1" DataIndex="TipoTel" runat="server" Text="Tipo Telefone">
                                    </ext:Column>
                                    <ext:Column ID="Column2" runat="server" DataIndex="Tel" Text="Telefone">
                                    </ext:Column>
                                    <ext:ComponentColumn Width="200" ID="ComponentColumn1" runat="server" Editor="true"
                                        DataIndex="GrupoMotivo" Text="Grupo Motivo">
                                        <Component>
                                            <ext:ComboBox ID="CboGrupoMotivacao" runat="server" DisplayField="Descr" ValueField="Id"
                                                EmptyText="Selecione..." Editable="false" QueryMode="Local" TriggerAction="All">
                                                <Listeners>
                                                    <Select Fn="cboGrupoMotivacao_OnSelectItem">
                                                    </Select>
                                                </Listeners>
                                                <Store>
                                                    <ext:Store ID="Store2" runat="server">
                                                        <Model>
                                                            <ext:Model ID="Model1" runat="server">
                                                                <Fields>
                                                                    <ext:ModelField Name="Descr" Mapping="DS_GRUPO_MOTOVACAO_AGENDAMENTO">
                                                                    </ext:ModelField>
                                                                    <ext:ModelField Name="Id" Mapping="ID_GRUPO_MOTIVACAO_AGENDAMENTO">
                                                                    </ext:ModelField>
                                                                </Fields>
                                                            </ext:Model>
                                                        </Model>
                                                    </ext:Store>
                                                </Store>
                                            </ext:ComboBox>
                                        </Component>
                                    </ext:ComponentColumn>
                                    <ext:ComponentColumn Width="200" ID="ComponentColumnMotivacao" IDMode="Static" runat="server"
                                        Editor="true" Text="Motivo">
                                        <Component>
                                            <ext:ComboBox ID="CboMotivacao" IDMode="Static" runat="server"
                                                EmptyText="Selecione..." ForceSelection="true" AllowBlank="false">
                                                <Listeners>
                                                    <Select Handler="cboMotivacao_Select(this)">
                                                    </Select>
                                                    
                                                    
                                                </Listeners>
                                            </ext:ComboBox>
                                        </Component>
                                    </ext:ComponentColumn>
                                    <ext:DateColumn DataIndex="DtAgendamento" Disabled="true" ID="ColumnDtAgendamento" IDMode="Static"
                                        runat="server" Text="Dt Agendamento" Format="yyyy-MM-dd">
                                        <Editor>
                                            <ext:DateField ID="DfDtAgendamento" runat="server" Format="yyyy-MM-dd" />
                                        </Editor>
                                        <EditorOptions CompleteOnEnter="true" IgnoreNoChange="true" />
                                       
                                    </ext:DateColumn>
                                    <ext:CommandColumn ID="ImageCommandColumn1" Align="Center" runat="server">
                                        <Commands>
                                            <ext:GridCommand Icon="Disk" CommandName="CmdGravar">
                                            </ext:GridCommand>
                                        </Commands>
                                    </ext:CommandColumn>
                                </Columns>
                            </ColumnModel>
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>
                <ext:Panel runat="server" Region="Center">
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </asp:Content>

    the server side code:

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using credenciada.nossatv.tv.br.Classes.VO;
    using credenciada.nossatv.tv.br.Classes.Facade;
    using Ext.Net;
    
    namespace credenciada.nossatv.tv.br.Agendamento
    {
        public partial class Agendamento : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                    if (!X.IsAjaxRequest)
                    {
                        PreencherDadosEPopularGrid();
                        CarregarComboGrupoMotivacao();
                    }
                }
                catch (Exception)
                {
    
                    throw;
                }
            }
        
    
            private DataTable GetTelefones(DataSet dsDadosOS, AgendamentoVO loAgendamentoVO)
            {
                return dsDadosOS.Tables[1];
            }
    
            private AgendamentoVO GetAgendamentoVO()
            {
                int numOs = Convert.ToInt32(Session.Get<string>(SessionKeys.OS_Agendamento_Habilitacao));
                return new AgendamentoVO
                {
                    NumeroOS = numOs
                };
            }
    
            private void PreencherDadosEPopularGrid()
            {
    
                AgendamentoVO loAgendamentoVO = GetAgendamentoVO();
    
                DataSet ds = new AgendamentoFacade().GetDadosOS(loAgendamentoVO);
    
            
                DataTable dtTelefones = GetTelefones(ds, loAgendamentoVO);
    
              
                CarregarGridTelefones(dtTelefones);
            }
    
            private void CarregarGridTelefones(DataTable dtTelefone) //Fill the GridPanel
            {
                GridAgendamento.GetStore().DataBind(dtTelefone);
            }
            private DataSet GetGrupoMotivacaoAgendamento(AgendamentoVO loAgendamentoVO)
            {
                try
                {
                    AgendamentoFacade loAgendamentoFacade = new AgendamentoFacade();
    
                    DataSet dsGetGrupoMotivacao = loAgendamentoFacade.GetGrupoMotivacaoAgendamentoHabilitacao(loAgendamentoVO);
    
                    return dsGetGrupoMotivacao;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
    
            private void CarregarComboGrupoMotivacao() // Fill de first combobox
            {
                DataSet ds = GetGrupoMotivacaoAgendamento(new AgendamentoVO
                {
                    ID_GRUPO_MOTIVACAO_AGENDAMENTO = 0
                });
    
                CboGrupoMotivacao.GetStore().DataBind(ds);
            }
    
    
    
            private DataSet GetMotivacaoAgendamentoHabilitacao(AgendamentoVO loAgendamentoVO)
            {
                AgendamentoFacade loAgendamentoFacade = new AgendamentoFacade();
    
                return loAgendamentoFacade.GetMotivacaoAgendamentoHabilitacao(loAgendamentoVO);
            }
    
            [DirectMethod]
            public List<AgendamentoVO> GetMotivacao(int idGrupoMotivacaoAgendamento) // Get the List that return to client site
            {
                DataSet ds = GetMotivacaoAgendamentoHabilitacao(new AgendamentoVO
                {
                    ID_GRUPO_MOTIVACAO_AGENDAMENTO = idGrupoMotivacaoAgendamento
                });
    
                return (from dr in ds.Tables[0].AsEnumerable()
                        select new AgendamentoVO
                        {
                            ID_MOTIVACAO_AGENDAMENTO = Convert.ToInt32(dr["ID_MOTIVACAO_AGENDAMENTO"]),
                            DS_MOTIVACAO_AGENDAMENTO = dr["DS_MOTIVACAO_AGENDAMENTO"].ToString()
                        }).ToList<AgendamentoVO>();
    
            }
        }
    }
    Thank you

    Click image for larger version. 

Name:	BeforeEditdateField.jpg 
Views:	78 
Size:	75.3 KB 
ID:	5429Click image for larger version. 

Name:	AfterEditDateField.jpg 
Views:	81 
Size:	75.0 KB 
ID:	5428
    Last edited by ascsolutions; Jan 17, 2013 at 2:30 PM.

Similar Threads

  1. Populate FormPanel: problems with Combobox
    By Ewerton93 in forum 2.x Help
    Replies: 0
    Last Post: Jan 16, 2013, 3:16 PM
  2. Replies: 4
    Last Post: Mar 20, 2012, 1:27 PM
  3. Problems with ComboBox Two Columns
    By ascsolutions in forum 1.x Help
    Replies: 2
    Last Post: Jan 19, 2012, 12:32 PM
  4. Problems with linked combobox/superboxselect
    By wilbur60 in forum 1.x Help
    Replies: 0
    Last Post: Feb 25, 2011, 8:34 PM
  5. Replies: 4
    Last Post: Nov 25, 2008, 5:53 PM

Tags for this Thread

Posting Permissions