DbNetSuiteVS 1.0 Now Available  

Tips / FAQ

Changing the default text editor
Can I change the default text editor in the edit dialog to be HTML
Show Answer
You will need to use the editRowInitialistion property e.g.

...
dbnetgrid1 = new DbNetGrid("dbnetgrid1")
dbnetgrid1.editRowInitialisation = "editInitialise"
dbnetgrid1.loadData()
}

/////////////////////////////////////////////////////////////////////////////
function editInitialise( editControl )
/////////////////////////////////////////////////////////////////////////////
{
editControl.editorType.value = 'html'
}

...

Hide Answer


Trapping a double click on the grid
How do I override the default ondblclick behavior which opens the edit dialog
Show Answer
You can assign a method to the onDoubleClick event which will override the default behaviour e.g.

...
  dbnetgrid1.onDoubleClick = "displayRow"
  dbnetgrid1.loadData()
}

function displayRow( click )
{
  var cellClicked = click.srcElement
  var row = getParentElement(cellClicked, "TR")
  alert("Row: " + row.id)
}
...

Show Me View Source

Hide Answer


Adding additional heading information
How can I add additonal heading information to the grid
Show Answer
Use the onPageLoaded event to add the additional heading information to the grid e.g.

...
  dbnetgrid1.onPageLoaded = addHeading
  dbnetgrid1.loadData()

}

function addHeading()
{
  var table = dbnetgrid1.table
  var row = table.insertRow(0)
  row.className = "headingRow"
  var cell = row.insertCell()
  var cell = row.insertCell()
  cell.style.textAlign = "center"
  cell.colSpan = 3
  cell.innerText = 'Address'
}
...

Show Me View Source

Hide Answer


Adding buttons to the toolbar
Can I add my own buttons to the toolbar.
Show Answer
Yes you can do it like this:

window.onload = initGrid

var customersGrid

//////////////////////////////////////////////////////////////////////////////////////////////
function initGrid()
//////////////////////////////////////////////////////////////////////////////////////////////
{
  customersGrid = new DbNetGrid( "dbnetgrid1" )

  with ( customersGrid )
  {
    connectionString = "samples"
    fromPart = "[products]"

    var btn = addToolbarButton( "/dbnetgrid/images/go.gif", "", 0, null, "buttonClicked" );
    btn.id = "button1";
    btn.style.height = "23px";
    
    btn = addToolbarButton( "/dbnetgrid/images/go.gif", "", 6, null, "buttonClicked" );
    btn.id = "button2";
    btn.style.height = "23px";

    loadData()
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////
function buttonClicked(event)
//////////////////////////////////////////////////////////////////////////////////////////////
{
  alert(event.srcElement.id + ' clicked')
}

Show Me View Source

Hide Answer


Selecting/sorting by the day of the week
I am looking to sort by both day of the week, and purely by date.
Show Answer
You can use a database function to extract the date of the week and then use the transform property to convert the numeric value to to a textual one.

Show Me View Source

Hide Answer


Selecting multiple rows
Can I select multiple rows.
Show Answer
You can use the transform property to create a check box in a new column and then use the onPageLoaded event add a 'Select' button. e.g.


...
  dbnetgrid2.setColumnProperty("checkbox","transform:makeCheckBox")
  dbnetgrid2.onPageLoaded = addSelectButton
  dbnetgrid1.loadData()
}


function makeCheckBox(cell)
{
  cell.innerHTML = '<input id=selector type=checkbox>'
}

function addSelectButton()
{
  var table = dbnetgrid2.table
  var row = table.insertRow(-1)
  var cell = row.insertCell(-1)
  cell.colSpan = table.rows[0].cells.length
  cell.style.textAlign = 'right'
  cell.innerHTML = '<button onclick=selectProducts()>Select</button>'
}
...

Show Me View Source

Hide Answer


Changing the grid style
Can I change the grid style without having to set it for each column.
Show Answer
Yes, you can use CSS e.g.

<style>
table.dbnetgrid td {padding:5px;font: normal 11px verdana, tahoma, helvetica, sans-serif; }
</style>

Show Me View Source

Hide Answer


Script Error Notification
I'm not getting any notification of scripting errors on my page
Show Answer
You need to enable the 'Display a notification about everty script error' setting.

You can do this from the browser menu:

Tools --> Internet Options --> Advanced tab

Hide Answer


Referencing grid columns
Do I have easy access to values in other cells of the grid during a transform

That is,when I set a transform can I evaluate the value of another cell in the grid and then set the value of the current cell.
Show Answer
Yes, the transform function is passed a reference to the cell, from that cell reference you can get a reference to the parent row and from there the other cells in the row.

You should use the columnIndex method to get the cell index just in case the column index is changed. e.g.


  ...
  dbnetgrid1.setColumnProperty('city','transform:colourCity')
  ...

  //////////////////////////////////////////////////////////////////////////////////////////////
  function colourCity(cell)
  //////////////////////////////////////////////////////////////////////////////////////////////
  {  
    var row = getParentElement(cell, "TR")
    var regionIdx = dbnetgrid1.columnIndex('region')
    if (regionIdx == -1)
      return

    var region = row.cells[regionIdx].innerText
    var col = ''
    switch (region)
    {
      case 'WY':
        col = 'yellow'
        break;  
      case 'WA':
        col = 'darkorange'
        break;  
      case 'SP':
        col = 'gold'
        break;
    }
    cell.style.backgroundColor = col
  }
  ...

Show Me View Source

Hide Answer


Initialising the value of a date/time in the edit dialog
How can I initialise the value of a date and time field in the edit dialog
Show Answer
Use the editRowInitialisation property
See example

Show Me View Source

Hide Answer


Currency formatting
How can I format a display column in the format $99,999,999.99
Show Answer
You can use the setColumnProperty method to set the format of a column e.g.

...
dbnetgrid1.setColumnProperty('total','format:c')
...

Show Me View Source

Hide Answer


Scrolling the grid but not the toolbar
Is it possible to scroll the grid but to keep the toolbar in a fixed position.
Show Answer
Yes. You can put the toolbar in it's own element by giving another element the same id but with a ".toolbar" extension. e.g.

<div id=dbnetgrid1.toolbar></div>

You can then use the overflow style property on the element containing the grid e.g.

<div id=dbnetgrid1 style='overflow-y:auto; height:100; border:1px solid gainsboro;'></div>

Show Me View Source

Hide Answer


Adding noWrap to grid columns
How can I keep the height of my grid rows constant by preventing the data in the cells from wrapping.
Show Answer
Use the noWrap property with the setColumnProperty method. e.g.

setColumnProperty("notes","noWrap:true")

To apply it to all columns in the grid, use CSS to add the nowrap property;

...
<style>
  table.dbnetgrid td {white-space:nowrap}
</style>
...

Show Me View Source

Hide Answer


Performing server-side processing in response to an edit
I want to send an email whenever a record gets changed, how can I do this ?
Show Answer
You can use the onEditApply event to invoke a custom ASPX page using a hidden IFRAME. e.g.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>DbNetGrid Demo</title>

<script src="/dbnetgrid/dbnetgrid.js"></script>
<script>
window.onload = initGrid

//////////////////////////////////////////////////////////////////////////////////////////////
function initGrid()
//////////////////////////////////////////////////////////////////////////////////////////////
{  
  var dbnetgrid1 = new DbNetGrid("dbnetgrid1")
  with (dbnetgrid1)
  {  
    fromPart = 'products'
    primaryKeyColumn = "productid"
    onEditApply = "editApplied"
    loadData()
  }
}

//////////////////////////////////////////////////////////////////////////////////////////////
function editApplied( editControl )
//////////////////////////////////////////////////////////////////////////////////////////////
{
  var productID = editControl.inputControl('productid').value
  var url = editControl.grid.virtualDir + "samples/sendmail.aspx?productid=" + productID + "&mode=" + editControl.mode
  
  var httpRequest = new HttpRequest();
  httpRequest.get( url );
  alert( httpRequest.xmlRequest.responseText );
}

</script>

</head>
<body>
  <div id=dbnetgrid1></div>
</body>
</html>

Hide Answer


Controlling the number of records selected
I have a very large view of nearly a million rows. I want to be able to allow my users to select from the data source but prevent them from simply selecting all the records.
Show Answer
You can use the searchAction property to assign a handler which can count the number of matched records and then conditionally perform the search based on the total number of matches.

In the accompanying example the searchAction method will only perform the search if less than 500 records are returned.

Show Me View Source

Hide Answer


Changing the default search dialog match option
The Search dialog has 2 options "Match all of the search criteria" and "Match at least one of the search criteria". By default it shows "Match all of the search criteria", how do I make the second option to be the default value.
Show Answer
You can set the "searchDialogJoinOperator" property in your application e.g.

  var dbnetgrid1 = new DbNetGrid("dbnetgrid1")
  ...
  dbnetgrid1.searchCriteriaJoinOperator = "or"

Alternatively, if you want it to apply to all of your grids then you can change the dbnetgrid.js file e.g.

  DbNetGrid.prototype.searchDialogJoinOperator = "or";

Hide Answer


Setting a column style based on a value in an adjacent column
The Part Number column needs to be formatted based on the Short Column. If the Short Column is 1, make the background red, if it is 0 leave the default, and if it is 2, make it yellow.

Can I do this ?
Show Answer
Yes. You can use the transfom property to call a formatting function. You can locate the index of other columns in the same row using the columnIndex method.

In the example the city column colour set based on the value in the region column

Show Me View Source

Hide Answer


Setting the alignment of a nested grid
My nested grid ia appearing right-aligned within the master grid. How can I change this to left alignment?
Show Answer
You can change the default alignment of a nested by setting the textAlign style to either 'left' or 'right' while configuring the nested grid

Show Me View Source

Hide Answer


Hiding '+' image on a nested grid where the child contains no rows
How do I hide the '+' image on a nested grid where the corresponding child does not contain any rows?
Show Answer
Use the onPageLoaded event with selectData to pre-select the contents of the child grid.
See example.

Show Me View Source

Hide Answer


Adding line numbering to the grid
Can I add line numbering to the grid ?
Show Answer
Yes, you can use the onPageLoaded event like this:

...
headings = [" ","Customer Code","Customer Name","Address","City","Region","Phone","Fax"]
selectPart = ["' '","customerid","companyname","address","city","region","phone","fax"]
onPageLoaded = addLineNumber
...

function addLineNumber()
{
var table = grid.table
for (var i=1;i<table.rows.length;i++)
{
  var c = table.rows[i].cells[0]
  c.style.backgroundColor = 'whitesmoke'
  c.style.textAlign = 'right'
  c.innerText = i + ((grid.pageNumber -1) * grid.pageSize)
}
}

Show Me View Source

Hide Answer


Applying a password style to an input box in an edit dialog
How can I make an input box in the edit dialog into a password control where entered characters appear as '*'?
Show Answer
You can use the setEditColumnProperty method to set the 'elementType' property, like this;

...
dbnetgrid1.setEditColumnProperty('postalcode',"elementType:password")
...

Show Me View Source

Hide Answer


Displaying a time in 12 hour format
How can I display a time in 12 hour format ?
Show Answer
Use can pass a custom formatting string to the format property of the setColumnProperty method. The example below will display the value 16:55 as 4:30 PM.

  ...
  setColumnProperty("start_time", "format:h:mm tt")
  ...

Hide Answer


Changing the table borders and alternating row colour style
I want to be able to alternate the grid row colours every 2 rows and show only vertical lines, can I do this.
Show Answer
You set the odd and even row classes on the grid table using the onPageLoaded event and alter the default css. See the example.

Show Me View Source

Hide Answer


Drag and Drop within a frame
If my grid is inside a <FRAME> or <IFRAME> then the "Drag and Drop" feature does not work.
Show Answer
Assign a border for the body of the document e.g.

<body onload=initialise() style='border:1pt solid white'>

The reason this works is a mystery to us as well :)

Hide Answer


Grid Navigation Using Arrow Keys
Can I use the arrow keys to move around the grid?
Show Answer
It is possible to trap the onkeydown event of the document and script navigation in response to the arrow keys. The attached example moves the current row in response to ARROW UP & DOWN and moves the current page in response to ARROW LEFT & RIGHT.

Show Me View Source

Hide Answer


Printing a single row
I would like to be able to print a single grid row
Show Answer
You can add your own "Print Row" button to the toolbar and call some custom DHTML (see example)

Show Me View Source

Hide Answer


Column headings on each page when printing
When I print the grid can I control the number of rows on each page and print the column headings at the top of each page.
Show Answer
Yes, by setting the printPageSize property to the number of rows you require on each page, for example;

...
dbnetgrid1.printPageSize = 10
...

Show Me View Source

Hide Answer


Using SQL Server "User Defined Functions"
I notice that in one of your web site examples you use "User Defined Functions" to present composite data in grid cells using the following selectPart

selectPart = ["title_id", "pubdate", "title", "dbo.titleRoyaltyandQty(title_id)"]

Is the source code for these functions available
Show Answer
CREATE FUNCTION titleRoyaltyandQty( @titleID varchar(10) )RETURNS VARCHAR(500)
AS
BEGIN

declare @rethtml varchar (500)
declare @royaltysum varchar(10)
declare @salesqty varchar(10)
declare @totalroyalty varchar(10)

SELECT @royaltysum = SUM(titles.royalty), @salesqty = SUM(sales.qty), @totalroyalty = SUM(sales.qty * titles.royalty)
FROM titles
JOIN sales ON titles.title_id = sales.title_id
where sales.title_id = @titleID

if (@totalroyalty is not null)
begin
  set @rethtml = '<table style="width:100%;font-size:8pt;border-collapse:collapse;border:1px; color:dimgray;">'
  set @rethtml = @rethtml + '<tr><td style="vertical-align:top;">Royalty</td><td style="text-align:right;">$' + @royaltysum + '</td></tr>'
  set @rethtml = @rethtml + '<tr><td>Sales Quantity</td><td style="text-align:right;">' + @salesqty + '</td></tr>'
  set @rethtml = @rethtml + '<tr style="border-top:1px solid black;"><td style="font-weight:bold; border-top:1px solid black;color:black">Total Royalty</td><td style="font-weight:bold; border-top:1px solid black;color:black">$' + @totalroyalty + '</td></tr>'
  set @rethtml = @rethtml + '</table>'
  
END
else
  set @rethtml = "No figures available<br>for this publication<br> "

return @rethtml
END

Hide Answer


Multiple nested grids on the same level
Can I have more than one nested grid on the same level.
Show Answer
No but you can provide a means of switching between different child grids on the same level.

Show Me View Source

Hide Answer


Collapsing nested grids programatically
I have a nested grid that I am using that needs to collapse any expanded rows when a different row is expanded. Can this be done?
Show Answer
Yes, you can collpase the expanded rows programatically

Show Me View Source

Hide Answer


Selecting Multiple Rows with Control & Shift Click
Can I select multiple rows within DbNetGrid using the standard Windows Control & Shift select behaviour?
Show Answer
Please see the example

Show Me View Source

Hide Answer


Removing the headings
Can I suppress the heading row ?
Show Answer
Yes, you can use the "onPageLoaded" event e.g.

...
onPageLoaded = "removeHeading"
...
//////////////////////////////////////////////////////////////////////////////////////////////
function removeHeading(grid)
//////////////////////////////////////////////////////////////////////////////////////////////
{
  grid.table.rows[0].style.display = 'none'
}

Hide Answer


Expanding child grids programatically
Can I expand all the child grids programatically.
Show Answer
Yes, but the code needs to wait for one child grid to open before attempting to open the next.

See example.

Show Me View Source

Hide Answer


Using 'WITH ROLLUP' to create totals and sub-totals
I am running SQL Server, can I use the "WITH ROLLUP" option to create totals and sub-totals.
Show Answer
Yes. The "WITH ROLLUP" option provides a very good way of adding totals and sub-totals.

There is an example of this in the demos.

http://www.dbnetgrid.com/dbnetgrid/demos.aspx?demoid=15

Hide Answer


Customising the Save/Export options
How can you drop Word and XML from the grid save options
Show Answer
The export/save options are controlled by a property called "saveOptions" which by default is defined with the string:

"[['html','HTML'],['word','Word'],['excel','Excel'],['xml','XML']]"

You can modify this property but is must be done on the behavior element rather than in script. To remove Word and XML from the save options you would define the saveOptions as follows:

<div id=dbnetgrid1 style='behavior:url(../dbnetgrid.htc)' saveOptions="[['html','HTML'],['excel','Excel']]"/>


Show Me View Source

Hide Answer


Searching a child grid
How can I select records in a parent grid based on data in a child grid.
Show Answer
You can include columns from the child grid in the search dialog for the parent grid. Use the searchAction event to modify the way the search criteria are applied to the parent grid.

The accompanying example shows how to select customers based on an order date.

Show Me View Source

Hide Answer


Dependent drop-down selection in the edit dialog
How can I populate a drop-down selection based on the value selected in another drop-down list
Show Answer
You need to use the onChange event on the top level drop-down list to call a function to load the values in the dependent drop-down list using the "applyProperty" method.

You also need to use the editRowInitialisation property to correctly initialise the dependent drop-down when updating records.

See the example for more information

Show Me View Source

Hide Answer


How can I join tables together
How can I display data from more than one table.
Show Answer
You can use the fromPart and joinPart properties to provide the information to join tables together

Show Me View Source

Hide Answer


Adding a title to the Edit Dialog
I am using a tree view to edit data. Sometimes it is confusing to decide which record in which table I am editing. I would like to programmatically add a custom title to the edit dialog screen.
Show Answer
You can do this using "editRowInitialisation" property to add some HTML to the Edit Dialog.

See example.

Show Me View Source

Hide Answer


Freezing columns
Can I fix a certain number of columns on the left of a grid and have columns on the right scroll relative to these columns.
Show Answer
Yes you can do by using 2 synchronised grids. See the the example for details of how to do this

Show Me View Source

Hide Answer


Adding a timestamp to an edit
How can I record the date a record was added or inserted
Show Answer
You can use the "rowValidation" property to populate an edit field automatically just prior to an edit being applied e.g.

with(dbnetgrid1)
{
...
  rowValidation = 'addUserIdAndDate'
...
}


function addUserIdAndDate(editControl)
{
  var d = new Date()
  var today = dbnetgrid1.culture.javascriptDateObjectToString(d)  
  if (editControl.mode == 'insert')
  {
    editControl.inputControl('CreatedOn').value = today
    editControl.inputControl('CreatedBy').value = userId
    
  }
  else
  {
    editControl.inputControl('editon').value = today
    editControl.inputControl('editby').value = userId
  }

return true
}

Hide Answer


Grid does not display data
When I run an application no grid is displayed, only the toolbar displays with 'undefined' next to some of the buttons.
Show Answer
This problem is caused by access being restricted to the server variable HTTP_REFERER. This is usually caused by a firewall.

If you are using Norton Personal Firewall, you can overcome this problem by doing the following;

1. Click 'Privacy Control'.
2. Remove the tick from the 'Enable Browser Privacy' check box and click 'OK'.
3. Refresh your application, and you should now see your data and the toolbar working correctly.

If this problem persists, contact support@dbnetlink.com

Hide Answer


Format Numbers with Thousand Seperators
I want to format a number to appear with seperators for the thousands. Eg; 123,456,789.23
Show Answer
Use setColumnProperty to set the format property, using the format specifier 'n'. For example;

...
dbnetgrid1.setColumnProperty("unitprice", "format:n")
...


Show Me View Source

Hide Answer


Moving to a specified row on another grid page
How can I allow the user to enter a key value and then find & highlight the matching row - even when it may be on another page?
Show Answer
You can use the grid's sql property to construct an array of the primary key values. When the user enters a key value, you can interrogate this array for the matching row and then, by reference to the offset and the page size, determine the page number and the row number of the required row.

Show Me View Source

Hide Answer


Display a single record over multiple rows
Can I display a second row of data for each record in the grid
Show Answer
Yes, you can use a combination of "dataOnlyColumns" and the "onPageLoaded" event.

Show Me View Source

Hide Answer


Page Totalisation
Can I show a page total for a numeric grid column?
Show Answer
Yes - use the onPageLoaded event to call a custom function which steps through the visible rows, totalises the column and inserts an adhoc row to contain the total value

Show Me View Source

Hide Answer


Grid Totalisation
Can I show the grand total for a particular column at the foot of each grid page?
Show Answer
Yes - use onPageLoaded to call a custom function which uses the selectData method to interrogate the database for the total. Remember to incude the value of the grid's filterPart property in the sql which you use to generate the grand total.

Show Me View Source

Hide Answer


Select Rows for Printing using Checkboxes
I would like to include a checkbox on ech row of the grid and use this checkbox to mark those rows which I want to include on the printed output.
Show Answer
You can use the 'transform' option with setColumnProperty to convert a dummy column into a checkbox and then store the state of the checkboxes in an associative array. You can then use the 'onGridPrint' event to set the display style of each row in the printed table depending on the values in the associative array.

Show Me View Source

Hide Answer


Using LDAP as a data source
Is it possible to query information from an LDAP (Lightweight Directory Access Protocol) data source?
Show Answer
You can access an LDAP data source using DbNetGrid by creating a SQL Server view of your LDAP information. For example you may want to query Active Directory user information. This can be done achieved by doing the following;

Create a linked server to your Active Directory with the following syntax;
sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADsDSOObject', 'adsdatasource'


Create a view in SQL server using OPENQUERY to select from Active Directory;
CREATE VIEW dbo.vw_AD_USER_INFO
AS

SELECT * FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, telephoneNumber,facsimileTelephoneNumber, sn FROM ''LDAP://DC=whaever,DC=domain,DC=org'' where objectClass = ''User''')

GO

For more information about performing a SQL Distributed Query by using ADSI and its limitations have a look at
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q299410


You can then create a DbNetGrid application in the normal way;

var dbnetgrid1 = new DbNetGrid("dbnetgrid1")
with (dbnetgrid1)
{
...
fromPart = "[vw_AD_USER_INFO]"
selectPart = "sn","facsimileTelephoneNumber","telephoneNumber","givenName","sAMAccountName","displayName","title"];
headings = ["Sn","Facsimiletelephonenumber","Telephonenumber","Givenname","Samaccountname","Displayname","Title"];
loadData()
...
}

Hide Answer


Vertical Heading Text
I would like to display the heading text vertically. Is this possible?
Show Answer
Yes, by using a combination of visual filter and the CSS writing-mode property.

Show Me View Source

Hide Answer


Deleting from a master grid if there are records present in a linked grid
I have a page containing linked grids and I want to delete records from the master grid. However, the delete button in the master is disabled if there are records in the linked grid. I have defined a delete cascade using triggers so this restriction is not necessary for me. Can I get around it?
Show Answer
This restriction is imposed to preserve referential integrity and prevent orphaned records. However, you can get around it my using the onRowSelected property in the master grid to call a custom function which enables the delete button.

Show Me View Source

Hide Answer


Positioning the grid on the last inserted record
I would like the grid to highlight the last record which I have inserted, rather than reload the grid and display the first record. Is this possible?
Show Answer
Yes - Within the onEditApply event you can use selectData and the grid's sql property to return the full set of matching records. You can then step through these records, keeping track of the page number and the row number as you go. You can then set the grid's pageNumber property sop that the correct page is displayed when the grid reloads and set an ad-hoc property of the grid to keep track of the row to be clicked when the page reloads.



Show Me View Source

Hide Answer


Using DbNetGrid with a stored procedure
Can I use a stored procedure as a data source for DbNetGrid
Show Answer
Yes, you can use the "procedure" and "procedureParameters" properties to link DbNetGrid to a stored procedure. e.g.

...
var dbnetgrid1 = new DbNetGrid("dbnetgrid1")
with (dbnetgrid1)
{
  connectionString = "northwind"
  procedure = "salesbycategory"
  procedureParameters["categoryname"] = "Beverages"
  procedureParameters["ordyear"] = 1996
  loadData()
}
...

Hide Answer


Applying changes to the printed grid
I have inserted an additional title row in my grid, but these changes are not displayed when I print the grid.
Show Answer
These changes will only be made to the visible grid. To apply changes to the printed grid, you will need to set the printType property to 'enhanced' and use the onGridPrint event and the gridToPrint property to apply the same changes before the grid prints.

The same applies to copying the grid and exporting the grid. When making changes to the copied grid set the copyType property to 'enhanced' and use the onGridCopy event and gridToCopy property. When making changes to the saved grid set the saveType to enhanced and use the onGridSave method and gridToSave property.


Show Me View Source

Hide Answer


Integrating DbNetGrid with ASP.NET authentication
Is there a way to control the editing capability of DbNetGrid based on the user name.
Show Answer
Yes, you can use server-side code to interrogate the identity of the authenticated user and set DbNetGrid properties accordingly.

You can download an example based on ASP.NET Forms authentication from here:

http://www.dbnetgrid.com/dbnetgrid/downloads/authenticate.zip

To install this example:

1. Extract the zip file into the DbNetGrid "samples" folder in the installation directory. This will create a folder called "authenticate" below the "samples" folder

2. Use IIS to make the "authenticate" folder into an IIS application

3. Run the application "default.aspx" in the authenticate" folder. i.e

http://servername/dbnetgrid2/samples/authenticate/default.aspx.


You should be presented with a login screen which will take you to an example DbNetGrid application that configures itself based on the logged in user.

Hide Answer


Adding an image to the grid
Can I add an image to the grid based on a text value in the cell
Show Answer
Yes, you can do this with the "transform" attribute.

Show Me View Source

Hide Answer


Nested and Linked Grids
Can I have a nested and linked grid associated with the same parent
Show Answer
Yes you can do this. See the example code.

Show Me View Source

Hide Answer


Toolltips in the edit dialog
Can I add my own tooltips to the controls in the edit dialog
Show Answer
You can use the setEditColumnProperty method to define tooltips for each field in the edit dialog, thus;

setEditColumnProperty("lastname", "hint:Enter the last name (surmname) of the user.")

Comments can also be added which display at the foot of the edit dialog as focus moves to the field;

setEditColumnProperty("description", "comment:<ol><li>The act, process, or technique of describing.<li>statement or an account describing something: <i>published a description of the journey; gave a vivid description of the game.</i><li> pictorial representation:<i> Monets ethereal descriptions of haystacks and water lilies. </i><li>A kind or sort: <i>cars of every size and description. </i></ol>")


Show Me View Source

Hide Answer


Passing information from another page
How can I set grid properties by passing information from another page
Show Answer
You can do this using the ASP.NET QueryString collection. You will need to define the grid on an ASPX page as it will need to pre-process the parameters in order to assign them to the grid properties. e.g.

If you invoke the grid page like this:

/apps/products.asp?categoryid=1

Then you can set the grid filter part like this:

...
dbnetgrid1.filterPart = "categoryid=<%=Request.QueryString["categoryid"]%>"
..


After pre-processing this will resolve to this:

...
dbnetgrid1.filterPart = "categoryid=1"
..

Hide Answer


Dealing with large amounts of text
Can I reduce the amount of space taken by large text fields.
Show Answer
Yes you use the transform attribute to modify the way the text is displayed. There are a number of ways this can be done:

- Truncate the data
- Put the text into a fixed-size scrollable DIV
- Truncate the data and put the full text into a 'Tooltip'
- Show the text in a pop up window

Show Me View Source

Hide Answer