Tag Archives: column

How to Hide a Spreadsheet Column in LibreOffice Calc Software & Sites 06 APR 2012

Seeing as Ubuntu ships with LibreOffice (forked from OpenOffice) as its default office suite these days, I guess I should try and get a little more familiar with its various time-saving tips and tricks, like this one noted here today.

(And If you don’t know what I’m talking about, then: “LibreOffice is the power-packed free, libre and open source personal productivity suite for Windows, Macintosh and GNU/Linux, that gives you six feature-rich applications for all your document production and data processing needs: Writer, Calc, Impress, Draw, Math and Base.”)

Anyway, Calc is LibreOffice’s spreadsheet application (similar to Microsoft Office’s Excel), and today’s handy little user interface tip shows us how to quickly and efficiently hide unwanted columns which you still want present, but just not visible in order to save on screen real estate.

To hide a column, grab with your mouse pointer the targeted column’s right hand edge, and begin resizing it like you normally would. In this case you want to shrink it, so in other words, drag towards the left. If you stop and release the mouse button before reaching the column’s left hand edge, the column will be shrunk to a smaller width.

And here is where it gets fun. Keep on resizing until you drag the right hand edge past the left hand edge! Releasing the mouse at this point will result in the column instantly hiding itself!

Which of course is pretty nifty! :)

MySQL: How to Check if a Column Exists in a Table with SQL CodeUnit 10 FEB 2011

To check if a column exists in a table with SQL using a MySQL database is pretty easy, thanks to the nifty SHOW COLUMNS command.

To find if a specific column exists, we simply extend the standard SHOW COLUMNS FROM statement with a LIKE parameter, which allows us to search for a specific string or for a partial string using the standard % modifier. If the statement returns a non-empty result set, we know the column exists.

For example:

SHOW COLUMNS FROM `table` LIKE 'column-name';

will return a empty result set if your table doesn’t have a column named ‘column-name’ in it. Similarly,

SHOW COLUMNS FROM `table` LIKE 'column-name%';

will return a result set containing all columns that start with ‘column-name’, e.g. ‘column-name-a’ and ‘column-name-b’ as well as plain old ‘column-name’ of course!


jQuery DataTables: How to Sort by a Specific Column on Load CodeUnit 04 APR 2010

I somehow missed this breezing through the available documentation on the DataTables website, but basically the question arose on how to force a table that has just been loaded (with Datatables applied naturally) to be sorted in a particular manner by default?

Well it turns out that the answer to this question is pretty simple indeed.

When constructing your dataTable object you can pass it an initializer parameter named aaSorting which essentially allows you to set which columns to sort on and also which direction to sort in.

Take a look at this sample dataTables initialization below:

$('#example').dataTable( {
		"bProcessing": true,
		"bServerSide": true,
		"iDisplayLength": 150,
		"bLengthChange": false,
		"sAjaxSource": "reservations_list.php",
		"aaSorting": [[ 5, "desc" ]]
	} );

If you look at the last parameter being fed to the constructor you’ll spot our aforementioned aaSorting being sneaked in there with an array value that is setting column six to be ordered in a descending fashion.

(You’ll note I say column six because obviously this is array based manipulation and as we all know, javascript utilizes zero-indexed arrays.)

And that is pretty much it. aaSorting allows us to set the default sorting pattern for any dataTables object.