[CLOSED] Rows empty grid using DataTable.

  1. #1

    [CLOSED] Rows empty grid using DataTable.

    Hi,

    I can do this?

    public void MontaColunasGrid(List<documento> documentos)
           {
               DataTable dt = new DataTable();
                               
               //Monta Coluna
               foreach (var doc in documentos)
               {
                   foreach (var item in doc.documento_indice)
                   {
                       if (!dt.Columns.Contains(item.indice.nome))
                       {
                           dt.Columns.Add(item.indice.nome);
                           this.GridPanelDocumento.ColumnModel.Columns.Add(new Column { DataIndex = "valor", Header = item.indice.nome }); 
                       }
                            
                   }
               }
     
               foreach (var doc in documentos)
               {
                   var i = 0;
                   DataRow row = dt.NewRow();
                   row[0] = doc.id;
                   foreach (var item in doc.documento_indice)
                   {
                       row[i] = item.valor;
                       i++;
                   }
                   dt.Rows.Add(row);
               }
     
               this.Store1.DataSource = dt;
               this.Store1.DataBind();
     
               if (X.IsAjaxRequest)
               {
                   this.Store1.Set("sortInfo", null);
                   this.Store1.Set("multiSortInfo", null);
                   this.GridPanelDocumento.Reconfigure();
               }
                
           }
    My store:

    <Store>
                                            <ext:Store ID="Store1" runat="server" OnSubmitData="StoreDocumento_Submit">
                                                <DirectEventConfig IsUpload="true" />                                            
                                                <Reader>
                                                    <ext:JsonReader>
                                                        <Fields>
                                                           <ext:RecordField Name="valor" Type="String"/>                                                  
                                                        </Fields>
                                                    </ext:JsonReader>                                                 
                                                </Reader>
                                            </ext:Store>
                                        </Store>
    The columns and rows are created, but the rows are empty.

    Any suggestion?

    Thanks for your helper.
    Last edited by Daniil; Jun 13, 2011 at 9:33 PM. Reason: [CLOSED]
  2. #2
    Hi,

    This
    <ext:RecordField Name="valor" Type="String" />
    expects a "valor" column in the DataTable.

    Is there such column?
  3. #3
    Hi not exist.

    It worked well + -. But the grid rows were without action. I can not select rows.

    private void AdicionarField(RecordField field)
            {
                if (X.IsAjaxRequest)
                {
                    this.Store1.AddField(field, false);
                }
                else
                {
                    this.Store1.Reader.Reader.Fields.Add(field);
                }
            }
    
    public void MontaColunasGrid(List<documento> documentos)
            {
                DataTable dt = new DataTable();           
                               
                //Monta Coluna            
                foreach (var doc in documentos)
                {                
                    foreach (var item in doc.documento_indice)
                    {
                        if (dt.Columns.Contains(item.indice.nome) == false)
                        {
                            
                            this.AdicionarField(new RecordField(item.indice.nome));                       
                            
                            dt.Columns.Add(new DataColumn(item.indice.nome) { ColumnName = item.indice.nome });
    
                            this.DocumentiIndice.Add(item);                        
                        }                        
                    }
                    break;
                }
    
                this.Store1.ClearMeta();
    
                foreach (var doc in documentos)
                {
                    var i = 0;
                    DataRow row = dt.NewRow();               
                    foreach (var item in doc.documento_indice)
                    {
                        row[i] = item.valor;
                        i++;
                    }
                    dt.Rows.Add(row);               
                }
                
                this.Store1.DataSource = dt;
                this.Store1.DataBind();
    
                foreach (var item in this.DocumentiIndice)
                {
                    this.GridPanelDocumento.ColumnModel.Columns.Add(new Column { DataIndex = item.indice.nome, Header = item.indice.nome });            
                }            
    
                if (X.IsAjaxRequest)
                {              
                    this.Store1.Set("sortInfo", null);
                    this.Store1.Set("multiSortInfo", null);
                    this.GridPanelDocumento.Reconfigure();
                    this.GridPanelDocumento.AddScript("{0}.store = {1};{0}.view.refresh(true);", this.GridPanelDocumento.ClientID, this.Store1.ClientID);
                }
                
            }
    Any suggestuin?
    Thanks.
  4. #4
    Cannot select a row on mouse click?
  5. #5
    Yes. Cannot select a row on mouse click.

    Error: Uncaught TypeError: Cannot read property 'rowIndex' of undefined
  6. #6
    I think it's not related with the store.

    Where do you use 'rowIndex'?

    Please provide a sample to reproduce.
  7. #7
    Hi Daniil

    The error was related to the store.

    Please, mark as solved.

    Thanks for your help.

Similar Threads

  1. Gridpanel with datasource shows empty rows
    By darylpeeters in forum 2.x Help
    Replies: 2
    Last Post: May 31, 2012, 1:03 PM
  2. Replies: 0
    Last Post: Jul 07, 2011, 8:19 PM
  3. Replies: 3
    Last Post: Nov 30, 2010, 11:07 AM
  4. Load Grid with X amount of empty rows
    By Tbaseflug in forum 1.x Help
    Replies: 0
    Last Post: Sep 19, 2009, 1:06 PM
  5. Replies: 6
    Last Post: Feb 11, 2009, 3:13 PM

Posting Permissions