jQWidgets Forums

jQuery UI Widgets Forums Grid Pin a column on the fly

This topic contains 3 replies, has 2 voices, and was last updated by  amit.dhall4 11 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Pin a column on the fly #48835

    amit.dhall4
    Participant

    Hi Is it possible to pin a column on the fly. Say for example I have column reorder enabled and I moved a column to left and now I want to pin it there. An example will be helpful. Thanks in advance.

    Pin a column on the fly #48887

    amit.dhall4
    Participant

    Hi Is it possible to pin a column on the fly. Say for example I have column reorder enabled and I moved a column to left and now I want to pin it there. An example will be helpful. Thanks in advance.

    Pin a column on the fly #48907

    Peter Stoev
    Keymaster

    Hi amit,

    You can use the “setcolumnproperty” method to set the column’s pinned property.

    Example:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title id='Description'>In this example, the first Grid column is pinned and will be always visible while scrolling.</title>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> 
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> 
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var url = "../sampledata/products.xml";
    
                // prepare the data
                var source =
                {
                    datatype: "xml",
                    datafields: [
                        { name: 'ProductName' },
                        { name: 'QuantityPerUnit' },
                        { name: 'UnitPrice', type: 'float' },
                        { name: 'UnitsInStock', type: 'float' },
                        { name: 'UnitsOnOrder', type: 'float' },
                        { name: 'ReorderLevel', type: 'float' },
                        { name: 'CategoryID', type: 'int' }
                   ],
                    root: "Products",
                    record: "Product",
                    id: 'ProductID',
                    url: url
                };
    
                var categories = {};
                var categoriesurl = '../sampledata/categories.xml';
    
                $.ajax({
                    async: false,
                    url: categoriesurl,
                    success: function (data, status, xhr) {
                        categories = $("Category", data);
                    }
                });
    
                $("#jqxgrid").jqxGrid(
                {
                    width: 670,
                    source: source,
                    sortable: true,
                    pageable: true,
                    ready: function()
                    {
                        $("#jqxgrid").jqxGrid('setcolumnproperty', 'ProductName', 'pinned', true);
                    },
                    autoheight: true,
                    columns: [
                      { text: 'Product Name', datafield: 'ProductName', width: 250 },
                      { text: 'Category', datafield: 'CategoryID', width: 80, cellsalign: 'right' },
                      { text: 'Quantity Per Unit', datafield: 'QuantityPerUnit', width: 200, cellsalign: 'right' },
                      { text: 'Unit Price', datafield: 'UnitPrice', width: 100, cellsformat: 'c2', cellsalign: 'right' },
                      { text: 'Units On Order', datafield: 'UnitsOnOrder', width: 110, cellsalign: 'right' },
                      { text: 'Reorder Level', datafield: 'ReorderLevel', width: 100, cellsalign: 'right' }
                   ]
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid">
            </div>
        </div>
    </body>
    </html>
    

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Pin a column on the fly #48917

    amit.dhall4
    Participant

    Yes that is what I was looking for Thanks 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.