[CLOSED] problem to render a grid to window from code behind

  1. #1

    [CLOSED] problem to render a grid to window from code behind

    Hello I try to create a grid from code behind. I already do that, on other project, but here it is not working.

    Here the code I use:

    ASPX:
                        <Window>
                            <ext:Window
                                ID="wndCalendarTech"
                                runat="server"
                                Closable="true"
                                CloseAction="Destroy"
                                Minimizable="false"
                                Maximizable="false"
                                Resizable="true"
                                Height="800"
                                Icon="Wrench"
                                Title="Presence calendar"
                                Width="1200"
                                Modal="False"
                                Layout="FitLayout">
                                <Items>
                                    <ext:Panel ID="panCalendarTech" runat="server" Border="false" >
                                        <Loader runat="server" Url="LoadCalendarTech.ashx" Mode="Component">
                                            <LoadMask ShowMask="true"></LoadMask>
                                        </Loader>
                                        <Listeners>
                                            <Show Handler="#{panCalendarTech}.removeAll(); #{panCalendarTech}.reload();" />
                                        </Listeners>
                                    </ext:Panel>
                                </Items>
                                <Buttons>
                                    <ext:Button  runat="server" Text="Close">
                                        <Listeners>
                                            <Click Handler="#{wndCalendarTech}.close();"></Click>
                                        </Listeners>
                                    </ext:Button>
                                </Buttons>
                            </ext:Window>
                        </Window>
    LoadCalendarTech.ashx:
    Imports System.Web
    Imports System.Web.Services
    Imports Ext.Net
    
    Public Class LoadCalendarTech
        Implements System.Web.IHttpHandler
    
        Dim VMWebservice As fr2techsrv01.VisualManagementServices = New fr2techsrv01.VisualManagementServices
    
        ''' <summary>
        ''' This page will return presence calendar window for all technicians.
        ''' When a user load the window, this function is called. The return result is a JSON structure that conatains all control definition to fill tab
        ''' </summary>
        ''' <param name="context"></param>
        ''' <remarks>The controls are dynamically made as the number of days in a mont can vary
        ''' </remarks>
        Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    
            context.Response.ContentType = "application/json" 'fix type of response object to return
    
            Dim MyComponents As List(Of AbstractComponent) = New List(Of AbstractComponent) 'a list of all components that will be created
    
            'geting data from database
            Dim ds As DataSet = VMWebservice.getDatas("SELECT * FROM Technicians_T ORDER BY Name", "data", "AccessVM", ConfigurationManager.AppSettings("ENV"))
            Dim myPanel As New TabPanel 'cretat the tabpanel that will receive all historic tabs
    
            'as precedent panels contains grid, we have to create grid structure and store for each grid
            'create elements needed by store
            Dim ProxyCalendar As New AjaxProxy.Config 'store's proxy
            Dim ReaderCalendar As New JsonReader 'store's reader
            With ReaderCalendar
                .Root = "data" 'define root property
            End With
            With ProxyCalendar 'set URL for store and different config parameters
                .Url = "jsonDAL/returnJSONCalendarTech.aspx"
                .Timeout = 300000000
                .Reader.Add(ReaderCalendar)
            End With
            Dim StoreCalendar As New Store 'now create store
            Dim ProxyCalendarTech As AjaxProxy = New AjaxProxy(ProxyCalendar)
            Dim ModelFieldCalendar As New Model 'the store's model
    
            'and create the model
            ModelFieldCalendar.Name = "Model_Calendar"
            ModelFieldCalendar.Fields.Add("id_tech") 'the fields that defines the store
            ModelFieldCalendar.Fields.Add("Name")
    
            'now we define field for next 30 days AM and PM
            Dim StarDate As Date = Date.Now
            Dim endDate = StarDate.AddDays(30)
            Dim i As Integer = 0
            Dim CurrenDate As Date = StarDate
            While CurrenDate <= endDate
                If CurrenDate.DayOfWeek <> DayOfWeek.Saturday And CurrenDate.DayOfWeek <> DayOfWeek.Sunday Then
                    ModelFieldCalendar.Fields.Add("DateAM" + i.ToString)
                    ModelFieldCalendar.Fields.Add("DatePM" + i.ToString)
                    CurrenDate = CurrenDate.AddDays(1)
                    i += 1
                Else
                    CurrenDate = CurrenDate.AddDays(1)
                End If
            End While
    
            With StoreCalendar 'fill store's parameter
                .ID = "Store_CalendarTech"
                .Model.Add(ModelFieldCalendar)
                .Proxy.Add(ProxyCalendarTech)
            End With 'all the store structure is created
    
            'now deal with the grid
            Dim grdCalendar As New GridPanel 'first the grid
            Dim colidTech As New Column 'second, its column
            Dim colName As New Column
            Dim colDate As List(Of Column) = New List(Of Column)
    
            With colidTech 'fill comumn structure with neede parameters
                .ID = "id"
                .DataIndex = "id_tech" 'from the store model structure
                .Width = 80
                .Hidden = True
            End With
            With colName
                .ID = "TechName"
                .DataIndex = "Name"
                .Width = 150
                .Text = "Technicians"
            End With
    
            CurrenDate = StarDate
            i = 0
            While CurrenDate <= endDate
                If CurrenDate.DayOfWeek <> DayOfWeek.Saturday And CurrenDate.DayOfWeek <> DayOfWeek.Sunday Then
                    Dim colAM As New Column
                    Dim colPM As New Column
                    With colAM
                        .ID = "colAM" + i.ToString
                        .DataIndex = "DateAM" + i.ToString
                        .Width = 50
                        .Text = "AM"
                    End With
                    With colPM
                        .ID = "colPM" + i.ToString
                        .DataIndex = "DatePM" + i.ToString
                        .Width = 50
                        .Text = "PM"
                    End With
                    colDate.Add(colAM)
                    colDate.Add(colPM)
                    CurrenDate = CurrenDate.AddDays(1)
                    i += 1
                Else
                    CurrenDate = CurrenDate.AddDays(1)
                End If
            End While
    
            'now fill grid structure with needed parameters
            With grdCalendar
                .Cls = "x-grid-custom" 'class
                .AutoScroll = True
                .ColumnLines = True
                .Height = 300
                .SortableColumns = False
                'the column model creates from previous columns created
                .ColumnModel.Columns.Add(colidTech)
                .ColumnModel.Columns.Add(colName)
                For j As Integer = 0 To colDate.Count - 1
                    .ColumnModel.Columns.Add(colDate)
                Next
                .Store.Add(StoreCalendar) 'and finally grid store
            End With
            myPanel.Add(grdCalendar)
    
            myPanel.Layout = "FitLayout"
    
            ComponentLoader.Render(myPanel)
    
        End Sub
    
        ''' <summary>
        ''' Added automaticaly at Handler page creation
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>value set to false by defualt means current HTTP Handler will be release at end of request.
        ''' set value to true will keep the HTTP Handler in memory for next equest, but it must be created thread-safe to work.
        ''' Better way is to set value as default, impact is a lost on performance because garbage collector will have a litle more job to do to release unused
        ''' memory
        ''' </remarks>
        ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
            Get
                Return False
            End Get
        End Property
    
    End Class
    and the error:
    'Transformer.NET.TokenNotUniqueException'
    If found some topic in the forum, but I think it I can't apply in my code (something related to call can only be made from Ajax request and not on pae load, but I'm not on page load at that point of my code, the window is opened from a click on a menu item in my desktop
    Last edited by Daniil; Apr 04, 2014 at 4:42 PM. Reason: [CLOSED]
  2. #2
    I guess the problem is related with this code
    For j As Integer = 0 To colDate.Count - 1
                    .ColumnModel.Columns.Add(colDate)
                Next
    You should use indexer to add column by index or use AddRange to add all columns without For instruction
  3. #3
    Quote Originally Posted by Vladimir View Post
    I guess the problem is related with this code
    For j As Integer = 0 To colDate.Count - 1
                    .ColumnModel.Columns.Add(colDate)
                Next
    You should use indexer to add column by index or use AddRange to add all columns without For instruction
    You'r totally right, I forget the indexe of the collumn. Shame on me.

    But another question? I want to have a multiple column header like that:

    2014/03/28 | 2014/03/29 |.....
    AM | PM |AM | PM |....

    How can I achieve that in the ashx file?

    OK, I change that part of code :

            CurrenDate = StarDate
            i = 0
            While CurrenDate <= endDate
                If CurrenDate.DayOfWeek <> DayOfWeek.Saturday And CurrenDate.DayOfWeek <> DayOfWeek.Sunday Then
                    Dim colDay As New Column
                    Dim colAM As New CheckColumn
                    Dim colPM As New CheckColumn
                    With colAM
                        .ID = "colAM" + i.ToString
                        .DataIndex = "DateAM" + i.ToString
                        .Width = 50
                        .Text = "AM"
                    End With
                    With colPM
                        .ID = "colPM" + i.ToString
                        .DataIndex = "DatePM" + i.ToString
                        .Width = 50
                        .Text = "PM"
                    End With
    
                    With colDay
                        .Text = CurrenDate.DayOfWeek.ToString + " " + CurrenDate.ToString("MM/dd")
                        .Width = 150
                        .Columns.Add(colAM)
                        .Columns.Add(colPM)
                    End With
    
                    colDate.Add(colDay)
                    CurrenDate = CurrenDate.AddDays(1)
                    i += 1
                Else
                    CurrenDate = CurrenDate.AddDays(1)
                End If
            End While
    It works ewcept I have not the title of AM/PM columns

    Click image for larger version. 

Name:	grid.png 
Views:	32 
Size:	2.0 KB 
ID:	8991 :
    Last edited by feanor91; Mar 28, 2014 at 1:49 PM.
  4. #4
    Could you, please, provide us with a runnable sample to reproduce the problem?
  5. #5
    Quote Originally Posted by Daniil View Post
    Could you, please, provide us with a runnable sample to reproduce the problem?
    Useless, by making an example I see it is something missing in the CSS look:

    Click image for larger version. 

Name:	pg.png 
Views:	31 
Size:	5.0 KB 
ID:	9061

    I use the x-grid-custom to have the custom grid in blue, so one of the css property must be missing to define multi header, if you know what is it, please tell me, in the mean time, I will look by myself.

    Edit:

    I find the problem it is the .x-group-sub-header property that must be overrided. It is only one problem left, a little gray or white line between the main headers and the sub headers, but I'm affraid it will be in the conception of the custom grid itself and not a CSS property.
    Last edited by feanor91; Mar 31, 2014 at 7:59 AM.
  6. #6
    Quote Originally Posted by feanor91 View Post
    It is only one problem left, a little gray or white line between the main headers and the sub headers, but I'm affraid it will be in the conception of the custom grid itself and not a CSS property.
    Could you, please, provide a test case?

Similar Threads

  1. Replies: 0
    Last Post: Aug 23, 2013, 11:16 AM
  2. Problem with Dynamic window, store and grid
    By bovo13 in forum 2.x Help
    Replies: 2
    Last Post: Dec 06, 2012, 10:36 AM
  3. [CLOSED] Problem with display grid in IFrame Ext.Net.Window Mode
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 23, 2012, 3:14 PM
  4. Replies: 0
    Last Post: May 07, 2009, 9:38 PM
  5. Replies: 2
    Last Post: Feb 19, 2009, 2:02 PM

Posting Permissions