Yearly Archives: 2011

Solution for UltraWebGrid missing scrollbars

I was working with classic Infragistics UltraWebGrid when noticed strange thing – even though scrollbars were enabled for the grid, the grid had fixed size and number of rows was bigger than the grid could display – no scrollbars appeared. For me it was a combination of grid being shown in a modal dialog in IE7 browser, but it could happen in other scenarios.

I also noticed when grid experienced any kind of user interaction (row added, row selected, checkbox cell checked etc.) scrollbars would magically appear. So the solution? Simulate user interaction. For example this code can be included in grid’s client-side InitializeLayout event:

function xMyGrid_InitializeLayout() {
    var oGrid = igtbl_getGridById('xMyGrid')
    oGrid.Rows.getRow(0).setSelected(true);
    oGrid.Rows.getRow(0).setSelected(false);
}

What happens here is first row of the grid is selected and an instant later unselected. It happens so fast that there’s no visual indication. But the grid gets its “user interaction” and scrollbars appear.

Microsoft with the sense of humor

Visited IE test-drive site in my Chrome browser today and was greeted with a cheery banner:

Microosft about Chrome

I guess that “Don’t forget to enable your partial hardware acceleration in the about:flags thingy…” is a veiled reference that IE9’s HTML5 is fully “hardware accelerated”. Still funny.

Update: Since Microsoft is abandoning their “native HTML5” party line the funny logo has been removed as well. Too bad, especially after comparing FPS on speed tests.

Stored Procedure in LINQ2SQL query

Linq2Sql has a great use of stored procedures – it converts them into methods which you can easily call using standardized .NET syntax. For example if you have SP:

ALTER PROCEDURE MyProcedure(MyParam int) ...

after dragging it into Linq2Sql designer you can call it in your .NET code like this:

Dim aResults = MyDbContext.MyProcedure(2011)

but there are 2 caveats. Continue reading →

Solution for WordPress CURL IPv6 error “Network is unreachable”

I am using FeedWordPress plugin on some of my sites to pull data from Google News RSS feeds. It was working fine, but after I moved to a new host, I started to get errors like:

Failed to connect to 2a00:1450:8006::63: Network is unreachable

Note the IPv6. Google have been supporting it for a while and news.google.com resolves to IPv6 first (similar error happens in WordPress admin dashboard in “Incoming Links” section). Unfortunately network of my new host didn’t support IPv6, so I had to find solution to force WordPress to use IPv4. Enter class-http.php. Continue reading →

String Aggregate in LINQ

In the past I described how to perform string aggregates in T-SQL. In this post I will show how strings can be concatenated in LINQ.

I am using ADO.NET data table as a source for the query, but LINQ being LINQ can pull data pretty much from anything so this example can easily be adjusted.

First things first, let’s create the source. As in T-SQL post I am using ol’ faithful Northwind database and getting data from the Employees table:

Dim oConn As New SqlConnection(sMyConnStr) : oConn.Open()
Dim oComm As New SqlCommand("SELECT Country, FirstName FROM Employees ORDER BY Country, FirstName", oConn)
Dim oAd As New SqlDataAdapter(oComm) : Dim oTable As New DataTable : oAd.Fill(oTable)

This will fill the datatable with employees’ first names and countries

Country FirstName
UK      Anne
UK      Michael
UK      Robert
UK      Steven
USA     Andrew
USA     Janet
USA     Laura
USA     Margaret
USA     Nancy

And now we want to group this by the country, combining first names into comma separated string. Continue reading →

Server-side “PageIndexChanging” event in UltraWebGrid

When Infragistics UltraWebGrid is not in LoadOnDemand mode, you need to rebind the grid to the data source in PageIndexChanged event for paging to work. What’s neat – before the rebind, grid is still on the old page, effectively giving you “BeforePageIndexChanged” or “PageIndexChanging” event in server-side code:

Protected Sub xuwgGrid_PageIndexChanged(sender As Object, e As UltraWebGrid.PageEventArgs) Handles xuwgGrid.PageIndexChanged

   'Page hasn't changed yet, collect data from the old page
   'Or cancel the rebind and remain on the old page

   'rebinding the grid to the datasource
    BindGrid()

   'New page is in effect

End Sub

Affecting page during WebDataGrid AJAX calls

When Infragistics WebDataGrid perform AJAX operations such as sorting and paging – it sends grid data directly to page’s DOM. But it also allows you to send your own custom data via server-side GridResponse object and its client-side counterpart. This feature allows you to establish effective link between server and client to perform custom operations otherwise available only during full postback or partial postback via update panel. There’re multiple cases where this can be used, let’s take a look at 3 most common:

  • Updating a related control with server-side generated data
  • Running a server-side generated JavaScript
  • Handling server-side errors, for example Session timeout

Continue reading →

SSRS: How to implement build-in parameter based on external parameter passed from ReportViewer

Imagine following scenario: an SSRS report has a dropdown list “lookup” parameter based on a stored procedure. When report runs, user selects a value from the dropdown, clicks “View Report” and report is generated. The challenge is – the “lookup” parameter (and underlying stored procedure) needed to be filtered by another “filter” parameter – and this one is not available in SSRS interface, but instead is passed from ReportViewer control from an ASP.NET application.

In order to successfully implement this use case 2 items need to be addressed:

First in the report itself parameters need to be ordered in such way so “filter” comes before “dropdown”. Parameters can easily be arranged in Business Intelligent Development Studio, by expanding Parameters node, selecting a parameter, and using arrow buttons in Report Data menu.

Second in the ASP.NET application, configuring ReportViewer control (setting credentials, server URL, report path and our “filter” parameter) needs to be done in Page_Init event in the “If Not IsPostback” block.

Implementing getNextRow in WebDataGrid

UltraWebGrid had a very convenient getNextRow() client-side function which returns next row in row collection. WebDataGrid does not have an analog, but it’s pretty easy to recreate the functionality:

function getNextRow(i_oRow) {
      var iRowIndex = i_oRow.get_index();
      var aRows = i_oRow.get_grid().get_rows();

      return aRows.get_row(iRowIndex + 1)
}

This function accept grid row as a parameter, gets the row’s index and return row with incremented index from grid row’s collection.

Solution for ‘previousSibling’ is null or not an object error in grouped UltraWebGrid

Infragistics UltraWebGrid offers standard keyboard navigation for record selection. For example you can click a row, and holding Shift key press Down Arrow to select multiple records. This works fine for a flat grid, but try this with grid in OutlookGroupBy mode and you’ll get an error ‘previousSibling’ is null or not an object:

Error selecting records in grouped UltraWebGrid

After some digging I found the culprit. Continue reading →