iASP_Grid Samples

Sample 1: Continue To Sample 2    Back To Samples
Click here >> Run Sample 1
Note:
If you haven't configured your Microsoft Access driver, please click here.

This Sample will demonstrates how to create an iASP_Grid object, connect to a database and retrieve the information from the specified table of the data base.  It  demonstrates iASP_Grid's support for column-wise sorting, and manipulation of column attributes individually.


 

Sample Code:

  <%

      Set Grid =  Server.CreateObject("Persits.AspGrid")
      Grid.FileName = "Sample1.asp"
      Grid.Connect "sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:Odbc:GridTest", "", ""
      Grid.SQL = "select id, name, phone from Departments"
      Grid.Cols(1).Hidden = True

      'Enable Sorting by Department Name

      Grid.Cols(2).CanSort = True

      '---------- Formatting code -----------

      Grid.Table.Width = 400

      Grid.Cols(2).Cell.Width = 250
      Grid.Cols(2).Header.Width = 250
      Grid.Cols(2).Cell.InputSize = 25
      Grid.Cols(2).Caption = "Department Name"

      Grid.Cols(3).Cell.Width = 150
      Grid.Cols(3).Header.Width = 150
      Grid.Cols(3).Cell.InputSize = 15
      Grid.Cols(3).Caption = "Phone Number"

      Grid.ColRange(2, 3).Header.BGColor = "#FFFFAA"
      Grid.ColRange(2, 3).Header.Font.Face = "Tahoma, Arial"
      Grid.ColRange(2, 3).Header.Font.Size = 2
      Grid.ColRange(2, 3).Cell.BGColor = "#90F0FE"
      Grid.ColRange(2, 3).Cell.Font.Face = "Tahoma, Arial"
      Grid.ColRange(2, 3).Cell.Font.Size = 2

  %>

  <HTML>
     <BODY>

  <% Grid.Display %>
  <% Grid.Disconnect %>

     </BODY>
     </HTML>
 
 

Description:

The first five steps for creating a Grid Object have already been discussed. See the main page of samples for details.

Grid.Cols(2).CanSort = True
Enables sorting for this column. If sorting for one or more columns is enabled, the ORDER BY clause in the Grid.SQL statement is no longer relevent.

Grid.Table.Width = 400
Sets the HTML <TABLE> tag's WIDTH attribute to 400. The Table method returns the Table object which can be used to set other <TABLE> attributes such as CELLSPACING, BORDER, etc.

Grid.Cols(2).Cell.Width = 250
Sets the WIDTH attribute of each column (the <TR> attribute in HTML terms) to a fixed pixel length of 250.  If this attribute is not set column may have variable length depending on the length of the data displayed.

Grid.Cols(2).Header.Width = 250
Sets the WIDTH attributes of the headings for column 2 (the <TH> attribute in HTML terms), which corresponds to the Departments.name field in our example.

Both Cell and Header methods return a Cell object which can be used to set  other <TD> and <TH> attributes, respectively, such as ALIGN, HEIGHT,  etc.

Grid.Cols(2).Cell.InputSize = 25
Sets the maximum number of characters accepted by the text field of the second column to a fixed length of 25 pixels.  The text fields are generated when the Grid is in the Edit/Add mode.

Grid.Cols(2).Caption = "Department Name"
Sets the heading name for column 2. By default, column names are the same as their corresponding database field names.

The next 4 lines do a similar job for column 3 (Departments.phone).

Grid.ColRange(2, 3).Header.BGColor = "#FFFFAA"
The ColRange(i, j). method has similar functionality to the Cols(i) method.  ColRange returns an  object representing a group of adjacent columns rather that just one column. Setting a property of such a "group" object will result in setting this property in all the columns it represents.  The line above is equivalent to the lines

     Grid.Cols(2).Header.BGColor = "#FFFFAA"
     Grid.Cols(3).Header.BGColor = "#FFFFAA"

Grid.ColRange(2, 3).Header.Font.Face = "Tahoma, Arial"
Set the FONT FACE attribute of each Header of column 2 and 3.

Grid.ColRange(2, 3).Header.Font.Size = 2
Sets the SIZE attributes of the <FONT> tag which will be placed within <TH> tags of columns 2 and 3.
 
  
Click here >> Run Sample 1
Back to Top Continue To Sample 2     Back To Samples

 

If you require technical support please send complete details about the problem you are having to support@halcyonsoft.com.


Copyright 1998-2000, Halcyon Software Inc. All rights reserved.