a developer's notes – a semi-technical web development BLOG

April 25, 2013

Hide Horizontal Scrollbar on jqgrid

From http://mageefamilyblog.blogspot.com/2011/06/jqgrid-horizontal-scroll-bars-when.html

If you add the scroll property of the jgrid to true, for dynamic (endldess) scrolling, it will add a unnecessary horizontal scroll bar. Use this to remove.

.ui-jqgrid-bdiv
{
overflow-x : hidden !important;
}

Here is the sample jqrid code:

 $(document).ready(function () {
            $('#jqgProducts').jqGrid({
                //url from wich data should be requested
                url: '@Url.Action("Products")',
                //type of data
                datatype: 'json',
                //url access method type
                mtype: 'POST',
                //columns names
                colNames: ['ProductID', 'ProductName', 'Supplier', 'Category', 'QuantityPerUnit', 'UnitPrice', 'UnitsInStock'],
                //columns model
                colModel: [
                            { name: 'ProductID', index: 'ProductID', align: 'left' },
                            { name: 'ProductName', index: 'ProductName', align: 'left' },
                            { name: 'Supplier', index: 'SupplierID', align: 'left', formatter: supplierFormatter },
                            { name: 'Category', index: 'CategoryID', align: 'left' },
                            { name: 'QuantityPerUnit', index: 'QuantityPerUnit', align: 'left' },
                            { name: 'UnitPrice', index: 'UnitPrice', align: 'left', formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2, prefix: '$'} },
                            { name: 'UnitsInStock', index: 'UnitsInStock', align: 'left', formatter: unitsInStockFormatter }
                          ],
                //pager for grid
                pager: $('#jqgpProducts'),
                //enable dynamic scrolling
                scroll: true,
                //enable npage request parameter
                prmNames: { npage: 'npage' },
                //initial sorting column
                sortname: 'ProductID',
                //initial sorting direction
                sortorder: 'asc',
                //we need to limit grid height so the scroll can appear
                height: '300px'
            });

April 24, 2013

In Windows 7, program windows are going behind the taskbar

Filed under: Daily Computing — Duy Nguyen @ 11:40 am
Tags: , , , , , , , ,

This will cause all browser’s status bar to be hidden! The only fix I know is

    1. Set the taskbar to Auto-hide.
    2. Reboot.
    3. Set taskbar NOT to auto-hide.
    4. Reboot again.

April 11, 2013

How to get a radio button’s label text with jQuery

Filed under: Javascript / JQuery — Duy Nguyen @ 9:59 pm
Tags: , , , , , ,

From stackoverflow

<input type="radio" name="value" id="product1">
<label for="product1">Product One</label>

You can obtain the label’s text with this jQuery code:

var text = $("input:checked + label").text();

The + signifies the adjacent selector. It will only select a label which has a checked input next to it.

If your label element has to be placed before the input, a single CSS selector can’t get a reference to it. Using jquery, you can however get a reference to the “previous child element” with the prev() function.

var text = $("input:checked").prev().text();

Parsing a Query String into an array with JavaScript

Filed under: Javascript / JQuery — Duy Nguyen @ 9:50 pm
Tags: , , , , , , , , ,

This brilliant method belongs to Joe Zim’s JavaScript Blog.

Here is the function.

    var parseQueryString = function( queryString ) {
        var params = {}, queries, temp, i, l;
     
        // Split into key/value pairs
        queries = queryString.split("&");
     
        // Convert the array of strings into an object
        for ( i = 0, l = queries.length; i < l; i++ ) {
            temp = queries[i].split('=');
            params[temp[0]] = temp[1];
        }
     
        return params;
    };

Using the function.

   function Test() {
        var qstring = "apple=7sf&orange=242&bananna=47614&cherry=8139";
        var myNewArray = parseQueryString(qstring);
    }

As you can see, you now have an array of all of your query strings!

parseQstring

April 9, 2013

Vertically Align Checkbox Next to a Div with an Image

Filed under: CSS / Styling — Duy Nguyen @ 12:58 pm
Tags: , , , , , ,

Check out this fiddle.

http://jsfiddle.net/eBY6Y/4/

April 6, 2013

Visual Studio 2012 Run tests in current context – Debug tests in current context

There is no longer a “Run tests in current context” or “Debug tests in current context“.

There is just a “Run Tests” and “Debug Tests” but they work exactly the same way as the old commands. If you right click within the body of a single test and select “Run Tests” it will run just that test now (as opposed to running all the tests in the class which was the behavior in the RC). If you click outside the method body but within the test class and select “Run Tests” it will run all the tests in that test class.

runTests

Create a free website or blog at WordPress.com.