If you’re trying to open an Excel 2003 XML file (SpreadsheetML) in Excel 2010 and getting “The file is corrupt and cannot be opened” error, try opening that file in WordPad (it will open as text XML) and save it back. Now try opening it in Excel 2010 again. You will still get “The file you’re trying to open is in a different format than specified by the file extension” warning, but after that the file should open.
Yearly Archives: 2011
Changing hosting. Again
Two years ago I switched to BlueHost. For a while it’s been a beautiful run, but lately the service has become horrible. Constant downtimes, and when sites were up they we unbelievable slow. So after a couple of MySQL DBs export/imports, after moving DNS hosting to my registrar GKG.NET – it’s:
Goodbye BlueHost, Hello Feral Hosting.
Infragistics supports good old traditional values
Good news everybody, according to Infragistics product Roadmap, upcoming NetAdvantage 2011 Release will support Windows 3.0/3.1
Finally cries of countless developers who code on Intel 386 machines with 16Mb of RAM have been answered. There’s no more need to look with envy at those fancy 32bit OS-es – things like charts, gauges and grids (pictured below is a Windows 3.1 implementation of WebDataGrid with running totals and custom slider control) are available to everybody.
Infragistics is known for innovations and being on the cutting edge. Kudos for not forgetting what got us there.
WebHierarchicalDataGrid: Locate cell by column name
If you need to get/set value of a specific cell in WHDG Row (which is of GridRecord or ContainerGridRecord type) the only way to do it is by Cell index e.g.
Protected Sub xMyGrid_InitializeRow(ByVal sender As Object, ByVal e As GridControls.RowEventArgs) Handles xMyGrid.InitializeRow e.Row.Items(15).Value = 42 End Sub
But what if you don’t know cell/column index and only column name is known? Then the trick is to find the index first. Consider following code:
Protected Sub xMyGrid_InitializeRow(ByVal sender As Object, ByVal e As GridControls.RowEventArgs) Handles xMyGrid.InitializeRow Dim oParent as GridControls.ContainerGrid = e.Row.Items.Grid Dim iColIndex as Integer if oParent.Columns("MY_COLUMN_NAME") IsNot Nothing iColIndex = oParent.Columns("MY_COLUMN_NAME").Index e.Row.Items(iColIndex).Value = 42 End If End Sub
It’s pretty straightforward, first you locate grid to which the row belongs, then locate column in that grid by name and get index of that column and finally locate cell in the row by that index. This method will work at any depth in the WHDG hierarchy.
Posting from HELLOTXT to Custom URL
HELLOTXT is an excellent service allowing you to update multiple social networks, blogs and microblogs at once. Among supported services – WordPress, Blogger, Delicious, Facebook, Twitter and many more.
One of the selections is Custom URL. What it does – it allows you to specify URL of your own site and then you’re free to do whatever you need with received data. This makes HELLOTXT services very expendable. For example natively it doesn’t support Russian LiveInternet network, but using Custom URL my site can accept posted data and then create a new LiveInternet entry via posting by email.
Setting Custom URL is very easy in HELLOTXT. You specify 2 fields:1st is Name*Code which can hold any data that your site can check to verify that call is authentic, 2nd field is URL – the URL of your site. Important! Make sure you specify actual file name, e.g. if it’s http://www.mysite.com/hellotxt/index.php – enter it as is, if your enter just http://www.mysite.com/hellotxt you may get 405 error “service not allowed”.
Once this part is setup your page will receive following FORM fields in HTTP request:
name, body, title, msg_code, image_code, video_code, audio_code, v
field “name” will have name*security code you specified in Custom URL setup. The rest depends on your setup, in my case (microblogging/status) field “body” had the actual message.
Making HoverCssClass work in WebDataTree
Infragistics WebDataTree control offers extensive support of CSS for tree styling. One of the options HoverCssClass is intended to alter tree node appearance when mouse pointer hovers over it:
Unfortunately it doesn’t seem to have any effect on the tree appearance. When I set that class to simple underline node:
.fnTreeHover {text-decoration:underline}
nothing happened. I found the workaround when I noticed that the tree is rendered as an ancor tag <A> inside of <LI> tag:
The solution is to apply style to this combination:
LI A:hover {text-decoration:underline}
Bingo. Now tree nodes are underlying when mouse is over them.
Individual Sorting of SELECT queries in the UNION
UNION is a very common operator used in SQL, it allows to combine result of multiple queries into one. Unfortunately if you want to sort this unified resultset sorting is applied to entire result at once. But what if you wan to sort queries-participants individually?
Let’s say you have 2 following queries from Northwind database:
SELECT TOP (5) CompanyName FROM Suppliers ORDER BY CompanyName
Aux joyeux ecclésiastiques Bigfoot Breweries Cooperativa de Quesos 'Las Cabras' Escargots Nouveaux Exotic Liquids
and
SELECT TOP (5) ProductName FROM Products ORDER BY ProductName
Alice Mutton Aniseed Syrup Boston Crab Meat Camembert Pierrot Carnarvon Tigers
And now you want to combine them into a single result, adding title lines to separate each result. The direct approach would be:
SELECT 'Suppliers' AS Name UNION SELECT TOP (5) CompanyName FROM Suppliers UNION SELECT 'Products' UNION SELECT TOP (5) ProductName FROM Products ORDER BY Name
But result is far from what we wanted
Alice Mutton Aniseed Syrup Aux joyeux ecclésiastiques Bigfoot Breweries Boston Crab Meat Camembert Pierrot Carnarvon Tigers Cooperativa de Quesos 'Las Cabras' Escargots Nouveaux Exotic Liquids Products Suppliers
Entire resultset is sorted uniformally and products are mixed with suppliers.
Continue reading →
UltraWebGrid: Hiding ServerOnly columns during export to Excel
If you’re using Infragistics UltraWebGrid with ExcelExporter and your grid has columns marked as “ServerOnly” – they’re visible in exported Excel worksheet even though the grid doesn’t show them onscreen. To hide these column in exported file, mark them as “Hidden” as well. This will have no additional effect on the way grid looks on screen, but the columns will be gone from the worksheet.
Fix for first release of Unique Article Wizard multisite WordPress plugin
If you’re using UAW plugin in your WordPress MU/3.0+ blog, starting version 3.1.26 it supports multisite environment (ability to have individual settings for subdomain blogs). But initial release had a bug resulting in errors of missing config.php as well as
permission denied – your token does not match our records
To fix this error, open file article_mods.php and locate function uaw_add_article. In global declaration after $win add , $blog_id. Then locate line
$uaw_config_file = getcwd() . ($win == "" ? '/config.php' : '\\config.php');
and replace it with
if ($blog_id == '1') {$uaw_config_file = getcwd() . ($win == "" ? '/config.php' : '\\config.php');} else {$uaw_config_file = getcwd() . ($win == "" ? '/config_'.$blog_id.'.php' : '\\config_'.$blog_id.'.php');}
Upload modified file to you UAW plugin directory, overwriting the old one and you’re good to go
Run JavaScript from both full and partial ASP.NET postback
A while back I posted a function that would run JavaScript from both full page postback and Infragistics async postback. But what if you’re using “normal” Microsoft AJAX where partial postbacks are controlled by ScriptManager and you need to run JavaScript on initial page load, full postback and from inside of Update Panel? And even in Infragistics the newer Aikido controls use ScriptManager for async communications.
Here is an overridden version of that RunJavaScript function for pages with ScriptManager:
Public Shared Sub RunJavascript(ByVal _ i_oScriptManager As Web.UI.ScriptManager, ByVal i_sJScode As String) If i_oScriptManager.IsInAsyncPostBack Then i_oScriptManager.RegisterStartupScript(i_oScriptManager.Page, _ i_oScriptManager.Page.GetType, "JSCode" & Rnd(1).ToString, _ i_sJScode, True) Else i_oScriptManager.Page.ClientScript.RegisterStartupScript( _ i_oScriptManager.Page.GetType, "JSCode" & Rnd(1).ToString, i_sJScode, True) End If End Sub
It accepts 2 parameters – ScriptManager control from the page and string with JavaScript code. Function checks if it’s an async postback and if so – calls ScriptManager’s RegisterStartupScript method, otherwise page’s RegisterStartupScript is used. Here’s an example of usage:
RunJavascript(Me.ScriptManager1, "alert('Hello world from any postback!');")