Showing posts with label jqwidget. Show all posts
Showing posts with label jqwidget. Show all posts

Saturday, November 15, 2014

jquery-window-events

ref: https://github.com/unyereno/power-show/blob/master/JQWidgets/demos/jqxwindow/jquery-window-events.htm

ref: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxwindow/jquery-window-events.htm?web\






<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="keywords" content="jQuery Window, Window Widget, Window" />
    <meta name="description" content="This demo demonstrates how to trigger some of the jqxWindow events like open, closed and moved." />
    <title id='Description'>This demo demonstrates how to trigger some of the jqxWindow events like open, closed and moved.</title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/gettheme.js"></script>
    <script type="text/javascript" src="../../scripts/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
    <script type="text/javascript">
        function capitaliseFirstLetter(string) {
            return string.charAt(0).toUpperCase() + string.slice(1);
        }
        function displayEvent(event) {
            var eventData = 'Event: ' + capitaliseFirstLetter(event.type);
            if (event.type === 'moved') {
                eventData += ', X: ' + event.args.x + ', Y: ' + event.args.y;
            }
            if (event.type === 'hide') {
                eventData += ', Dialog result: ';
                if (event.args.dialogResult.OK) {
                    eventData += 'OK';
                } else if (event.args.dialogResult.Cancel) {
                    eventData += 'Cancel';
                } else {
                    eventData += 'None';
                }
            }
            $('#events').jqxPanel('prepend', '<div style="margin-top: 5px;">' + eventData + '</div>');
            $('#events').jqxPanel('value', 1000);
        }
        function addEventListeners() {
            //Closed event
            $('#eventWindow').bind('close', function (event) {
                displayEvent(event);
            });
            //Dragstarted event
            $('#eventWindow').bind('moved', function (event) {
                displayEvent(event);
            });
            //Open event
            $('#eventWindow').bind('open', function (event) {
                displayEvent(event);
            });
            $('#showWindowButton').mousedown(function () {
                $('#eventWindow').jqxWindow('show');
            });
        }
        function createElements(theme) {
            $('#ok').jqxButton({ theme: theme, height: '25px', width: '65px' });
            $('#cancel').jqxButton({ theme: theme, height: '25px', width: '65px' });
            $('#eventWindow').jqxWindow({ maxHeight: 150, maxWidth: 280, minHeight: 30, minWidth: 250, height: 145, width: 270,
                theme: theme, resizable: false, isModal: true, modalOpacity: 0.3,
                okButton: $('#ok'), cancelButton: $('#cancel')
            });
            $('#events').jqxPanel({ theme: theme, height: '250px', width: '450px' });
            $('#showWindowButton').jqxButton({ theme: theme, width: '100px', height: '25px' });
        }
        $(document).ready(function () {
            var theme = $.data(document.body, 'theme', theme);
            if (theme == undefined) theme = '';
            addEventListeners();
            createElements(theme);
            $("#jqxWidget").css('visibility', 'visible');
        });
    </script>
</head>
<body class='default'>
    <div style="visibility: hidden;" id="jqxWidget">
        <input type="button" value="Show" id="showWindowButton" />
        <div style="width: 100%; height: 650px; border: 0px solid #ccc; margin-top: 10px;"
            id="mainDemoContainer">
            <div>Events Log:</div>
            <div id="events" style="width: 300px; height: 200px; border-width: 0px;">
            </div>
            <div id="eventWindow">
                <div>
                    <img width="14" height="14" src="../../images/help.png" alt="" />
                    Modal Window</div>
                <div>
                    <div>
                        Please click "OK", "Cancel" or the close button to close the modal window. The dialog
                        result will be displayed in the events log.
                    </div>
                    <div>
                    <div style="float: right; margin-top: 15px;">
                        <input type="button" id="ok" value="OK" style="margin-right: 10px" />
                        <input type="button" id="cancel" value="Cancel" />
                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

Thursday, October 16, 2014

jqwidgets: Grid Cells Formatting




http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-cellsformatting.htm

jqxGrid

The cellsformat property can be used for applying a formatting to the cell values. In the code example below is illustrated how to apply a custom formatting to a column with Date values and to a column with Numeric values.
Js
  1. $("#jqxgrid").jqxGrid(  
  2. {  
  3.     width: 670,  
  4.     height: 450,  
  5.     source: source,  
  6.     theme: theme,  
  7.     sortable: true,  
  8.     columns: [  
  9.         { text: 'Ship Name', datafield: 'ShipName', width: 250 },  
  10.         { text: 'Shipped Date', datafield: 'ShippedDate', width: 230, cellsformat: 'D' },  
  11.         { text: 'Freight', datafield: 'Freight', width: 130, cellsformat: 'F2', cellsalign: 'right' },  
  12.         { text: 'Ship Address', datafield: 'ShipAddress', width: 350 },  
  13.         { text: 'Ship City', datafield: 'ShipCity', width: 100 },  
  14.         { text: 'Ship Country', datafield: 'ShipCountry', width: 100 }  
  15.     ]  
  16. });  

Number format strings:
"d" - decimal numbers.
"f" - floating-point numbers.
"n" - integer numbers.
"c" - currency numbers.
"p" - percentage numbers. 


For adding decimal places to the numbers, add a number after the formatting string.
For example: "c3" displays a number in this format $25.256
Built-in Date formats:

// short date pattern
"d" - "M/d/yyyy",
// long date pattern
"D" - "dddd, MMMM dd, yyyy",
// short time pattern
"t" - "h:mm tt",
// long time pattern
"T" - "h:mm:ss tt",
// long date, short time pattern
"f" - "dddd, MMMM dd, yyyy h:mm tt",
// long date, long time pattern
"F" - "dddd, MMMM dd, yyyy h:mm:ss tt",
// month/day pattern
"M" - "MMMM dd",
// month/year pattern
"Y" - "yyyy MMMM",
// S is a sortable format that does not vary by culture
"S" - "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss" 


Date format strings:

"d"-the day of the month;
"dd"-the day of the month;
"ddd"-the abbreviated name of the day of the week;
"dddd"- the full name of the day of the week;
"h"-the hour, using a 12-hour clock from 1 to 12;
"hh"-the hour, using a 12-hour clock from 01 to 12;
"H"-the hour, using a 24-hour clock from 0 to 23;
"HH"- the hour, using a 24-hour clock from 00 to 23;
"m"-the minute, from 0 through 59;
"mm"-the minutes,from 00 though59;
"M"- the month, from 1 through 12;
"MM"- the month, from 01 through 12;
"MMM"-the abbreviated name of the month;
"MMMM"-the full name of the month;
"s"-the second, from 0 through 59;
"ss"-the second, from 00 through 59;
"t"- the first character of the AM/PM designator;
"tt"-the AM/PM designator;
"y"- the year, from 0 to 99;
"yy"- the year, from 00 to 99;
"yyy"-the year, with a minimum of three digits;
"yyyy"-the year as a four-digit number;
"yyyyy"-the year as a four-digit number.

Grid Cells Formatting Sample

Js
  1. $("#jqxgrid").jqxGrid(  
  2. {  
  3.     width: 670,  
  4.     height: 450,  
  5.     source: source,  
  6.     theme: theme,  
  7.     sortable: true,  
  8.     columns: [  
  9.         { text: 'Ship Name', datafield: 'ShipName', width: 250, sortable: false },  
  10.         { text: 'Shipped Date', datafield: 'ShippedDate', width: 230, cellsformat: 'D' },  
  11.         { text: 'Freight', datafield: 'Freight', width: 130, cellsformat: 'F2', cellsalign: 'right' },  
  12.         { text: 'Ship Address', datafield: 'ShipAddress', width: 350 },  
  13.         { text: 'Ship City', datafield: 'ShipCity', width: 100 },  
  14.         { text: 'Ship Country', datafield: 'ShipCountry', width: 100 }  
  15.     ]  
  16. });