Populating GridPanel at runtime, no erros are displayed but GridPanel remains empty

Page 1 of 2 12 LastLast
  1. #1

    Populating GridPanel at runtime, no erros are displayed but GridPanel remains empty

    Hi folks, I added a GridPanel to the page and with a direct event a wrote the following function that I pass a DataTable, which doesn't throw any error but the GridPanel doesn't show anything as well even though there are rows on the DataTable.
    Can you help me identify the problem?

    private void RenderGrid(DataTable Data)
        {
            for (int i = 0; i < Data.Columns.Count; i++)
            {
                gridResults2.ColumnModel.Columns.Add(new Column() { ColumnID = Data.Columns[i].ColumnName, Header = Data.Columns[i].ColumnName, DataIndex = Data.Columns[i].ColumnName });
            }
     
            Store store = new Store();
            store.DataSource = Data;
    
            JsonReader jsonReader = new JsonReader();
            for (int i = 0; i < Data.Columns.Count; i++)
            {
                jsonReader.Fields.Add(Data.Columns[i].ColumnName);
            }
             
            store.Reader.Add(jsonReader);
            gridResults2.Store.Clear();
            gridResults2.Store.Add(store);
            gridResults2.Reconfigure();
            gridResults2.DataBind();
        }
  2. #2
    Guys, this is the closest I could get, the columns are added and the GridPanel shows the correct number of rows returned by the query however I can't get the data to display, all cells are empty.
    Let me know if you have any ideas.
    Thanks,
    Paul

            //The GridPanel is already placed on the form with an empty Store.
    
            Store1.DataSourceID = string.Empty;
            Store1.DataSource = returnDataTable();
            Store1.DataBind();
    
            Store1.Reader.Reader.Fields.Clear();
            for (int i = 0; i < Data.Columns.Count; i++)
            {
                Store1.Reader.Reader.Fields.Add(Data.Columns[i].ColumnName);
            }
    
            gridResults2.ColumnModel.Columns.Clear();
    
            for (int i = 0; i < Data.Columns.Count; i++)
            {
                gridResults2.ColumnModel.Columns.Add
                    (new Column() { ColumnID = Data.Columns[i].ColumnName,
                                    Header = Data.Columns[i].ColumnName, 
                                    DataIndex = Data.Columns[i].ColumnName });
            }
    
            gridResults2.DataBind();
            gridResults2.Reconfigure();
  3. #3
    Ext.Net (Coolite) is an amazing product but every simple task is incredibly time consuming, the learning curve is a real show stopper, I've been struggling to get this simple task done but without any luck, I would appreciate if anyone could review the source and point me to the solution.
    Right now I came to the conclusion that Fields from the database are not displaying the data on the cell but dynamic fields, such as retrieving the date/time from SQL Server are displaying fine, this is becoming really confusing...
    Thanks,
    Paul
    Attached Files
  4. #4
    Hi,

    You shouldn't require the GridPanel call to .DataBind() and Reconfigure(). Can you post a full .aspx code sample demonstrating the whole scenario?
    Geoffrey McGill
    Founder
  5. #5
    Hi Geoffrey, thanks for responding, on my previous post there is an attachment with both .aspx and .cs files to test, you just need to enter your database connection string and a simple query to test it.
    Paul
  6. #6
    Hi paul-2011,

    Your code sample looks ok. I was not able to run because it throws an exception, but it appears everything is configured correctly.

    Can you confirm if "First" and "Today" are the correct case? These would be case-sensitive.

    If the Column Headers are being rendered, and the data rows are not, then I think either a problem with the RecordField .Name, or no data rows are being returned to your query.

    The following example demonstrates binding to a DataTable, see

    https://examples1.ext.net/#/GridPane...ata/DataTable/

    Hope this helps.
    Geoffrey McGill
    Founder
  7. #7
    Hi paul-2011,

    When posting future code-samples, please combine the .aspx+.cs into just a single .aspx file with no code-behind. You can also paste the code sample directly in the forum post and wrap in [CODE] tags.

    We prefer to be able to copy/paste a code sample into our demo project and run in a browser without having to make modifications. If we can quickly reproduce the issue locally, your questions will get answered fast.

    Generally speaking, forums posts in the "Community Help" forum which do not include a full code sample for us to quickly reproduce with a copy/paste will get skipped over by the Ext.NET Support and Dev members.
    Geoffrey McGill
    Founder
  8. #8
    Quote Originally Posted by geoffrey.mcgill View Post
    Hi paul-2011,

    Your code sample looks ok. I was not able to run because it throws an exception, but it appears everything is configured correctly.

    Can you confirm if "First" and "Today" are the correct case? These would be case-sensitive.

    If the Column Headers are being rendered, and the data rows are not, then I think either a problem with the RecordField .Name, or no data rows are being returned to your query.

    The following example demonstrates binding to a DataTable, see

    https://examples1.ext.net/#/GridPane...ata/DataTable/

    Hope this helps.

    • Can you confirm if "First" and "Today" are the correct case? These would be case-sensitive.
      • Positive, Today is just an alias for the SQL Server function GetDate()
    • If the Column Headers are being rendered, and the data rows are not, then I think either a problem with the RecordField .Name, or no data rows are being returned to your query.
      • The header and the rows are being rendered, just the values are not being rendered, see attachment.
    • The following example demonstrates binding to a DataTable, see
      • Thanks, I've seen all these samples including sample code from this forum, nothing seems to work though.
    Attached Thumbnails Click image for larger version. 

Name:	shot.jpg 
Views:	197 
Size:	15.7 KB 
ID:	1534  
  9. #9
    Hi,

    The "Today" Column is rendering correctly. There is an issue with the "First" Column.

    Please simplify your code sample down as much as possible, then view in a browser, then View>Source. Paste the html source rendered in the browser.
    Geoffrey McGill
    Founder
  10. #10
    sure, it seems like its returning always as null from the database:


    1
        2
        3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        4
        5<html xmlns="http://www.w3.org/1999/xhtml">
        6<head>
        7    <link rel="stylesheet" type="text/css"  href="/BackOffice/extjs/resources/css/ext-all-embedded-css/ext.axd?v=34580"  />
        8<title>
        9
       10</title>
       11    <script type="text/javascript" src="/BackOffice/extjs/adapter/ext/ext-base-js/ext.axd?v=34580"></script>
       12    <script type="text/javascript" src="/BackOffice/extjs/ext-all-js/ext.axd?v=34580"></script>
       13    <script type="text/javascript" src="/BackOffice/extnet/extnet-core-js/ext.axd?v=34580"></script>
       14    <script type="text/javascript" src="/BackOffice/extnet/extnet-data-js/ext.axd?v=34580"></script>
       15    <script type="text/javascript">
       16    //<![CDATA[
       17        Ext.onReady(function(){Ext.QuickTips.init();new  Ext.net.GridPanel({store:this.Store1=new  Ext.ux.data.PagingStore({proxyId:"Store1",autoLoad:true,reader:new  Ext.data.JsonReader({fields:[{name:"First"},{name:"Today"}]}),directEventConfig:{formProxyArg:"form1"},proxy:new   Ext.data.PagingMemoryProxy([{"First":null,"Today":"2010-08-27T18:28:35"},{"First":null,"Today":"2010-08-27T18:28:35"},{"First":null,"Today":"2010-08-27T18:28:35"},{"First":null,"Today":"2010-08-27T18:28:35"},{"First":null,"Today":"2010-08-27T18:28:35"},{"First":"","Today":"2010-08-27T18:28:35"},{"First":"","Today":"2010-08-27T18:28:35"},{"First":"","Today":"2010-08-27T18:28:35"},{"First":"","Today":"2010-08-27T18:28:35"},{"First":"","Today":"2010-08-27T18:28:35"}],   false)}),id:"GridPanel1",renderTo:"GridPanel1_Container",height:350,width:600,sm:this.RowSelectionModel1=new   Ext.grid.RowSelectionModel({proxyId:"RowSelectionModel1",singleSelect:true}),stripeRows:true,trackMouseOver:true,selectionMemory:false,cm:this.ColumnModel1=new   Ext.grid.ColumnModel({proxyId:"ColumnModel1",defaultSortable:true,columns:[{dataIndex:"First",header:"First"},{dataIndex:"Today",header:"Today"}]})});});Ext.net.ResourceMgr.init({id:"ResourceManager1",BLANK_IMAGE_URL:"/BackOffice/extjs/resources/images/default/s-gif/ext.axd",aspForm:"form1"});
       18    //]]>
       19    </script>
       20</head>
       21<body>
       22    <form name="form1" method="post" action="coolite.aspx" id="form1">
       23<div>
       24<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
       25<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
       26<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"  value="/wEPDwUJNDU1OTc1NTA4ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgUQUmVzb3VyY2VNYW5hZ2VyMQUKR3JpZFBhbmVsMdULJW/+9SnVjBZB4vZPsHb7WAAA"  />
       27</div>
       28
       29<script type="text/javascript">
       30//<![CDATA[
       31var theForm = document.forms['form1'];
       32if (!theForm) {
       33    theForm = document.form1;
       34}
       35function __doPostBack(eventTarget, eventArgument) {
       36    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
       37        theForm.__EVENTTARGET.value = eventTarget;
       38        theForm.__EVENTARGUMENT.value = eventArgument;
       39        theForm.submit();
       40    }
       41}
       42//]]>
       43</script>
       44
       45
       46<div>
       47
       48    <input type="hidden" name="__EVENTVALIDATION"  id="__EVENTVALIDATION"  value="/wEWAgKQ3YC9BwLk1b+VApThq7sRIxm1BEnv+0zff6OVg1a6" />
       49</div>
       50        
       51    <div id="GridPanel1_Container">
       52    
       53
       54
       55
       56
       57
       58
       59</div>  
       60    </form>
       61</body>
       62</html>
Page 1 of 2 12 LastLast

Similar Threads

  1. data not displayed in my gridPanel
    By emmanuel.sans.domenech in forum 1.x Help
    Replies: 1
    Last Post: Dec 02, 2011, 3:11 PM
  2. Alternate Row color in GridPanel not displayed?
    By venu.sn2009 in forum 1.x Help
    Replies: 0
    Last Post: Jun 24, 2011, 6:03 AM
  3. [CLOSED] Custom ComboBox in GridPanel Set Displayed Text
    By bethc in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 23, 2010, 8:14 AM
  4. Creating GridPanel at runtime
    By methode in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Oct 21, 2008, 12:39 PM
  5. Add Gridpanel to an Tabpanel in Runtime. BUG?
    By caiomarques in forum 1.x Help
    Replies: 3
    Last Post: Oct 09, 2008, 8:48 AM

Posting Permissions