Friday, 10 August 2018

How to get a cell value from w2ui grid?


var changeArr=w2ui['grid'].getChanges();

$(changeArr).each(function() {

 test = $(w2ui['grid'].get(this.recid)).attr("ColumnName");

//OR

test = w2ui['grid'].getCellValue(w2ui['grid'].get($(this).attr("recid"),true), column_index) ;

});


Tuesday, 7 August 2018

How to add total row at the bottom of a w2ui grid?


$('#grid').w2grid({
    name    : 'grid',
    columns: [               
        { field: 'recid', caption: 'ID', size: '50px' },
        { field: 'lname', caption: 'Last Name', size: '30%' },
        { field: 'fname', caption: 'First Name', size: '30%' },
        { field: 'email', caption: 'Email', size: '40%' },
        { field: 'sdate', caption: 'Start Date', size: '120px' },
        { field: 'sdate', caption: 'End Date', size: '120px' }
    ],
    records: [
        { recid: 1, fname: 'John', lname: 'doe', email: 'vitali@gmail.com', sdate: '1/3/2012' },
        { recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe@gmail.com', sdate: '2/4/2012' },
        { recid: 3, fname: 'Jin', lname: 'Franson', email: 'jdoe@gmail.com', sdate: '4/23/2012' },
        { recid: 4, fname: 'Susan', lname: 'Ottie', email: 'jdoe@gmail.com', sdate: '5/3/2012' },
        { recid: 5, fname: 'Kelly', lname: 'Silver', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 6, fname: 'Francis', lname: 'Gatos', email: 'vitali@gmail.com', sdate: '2/5/2012' }
    ],
    summary: [
        { recid: 10, fname: 'John', lname: 'doe', email: 'vitali@gmail.com', sdate: '1/3/2012' }
    ]
});


Source: http://w2ui.com/web/docs/1.5/w2grid.summary

Monday, 6 August 2018

How to hide search box in w2ui grid?


show: {
            //...
            toolbarSearch: false,
            searchAll: false,
            toolbarInput: false,
            //...
        },

Friday, 3 August 2018

InfoPath: How apply formatting rule of a date field?


Add the 'Date' field to the form, and change the control to 'Text Box'

Thursday, 2 August 2018

How to add custom buttons in w2ui grid?


toolbar: {
        items: [
            { type: 'break' },
            { type: 'button', id: 'mybutton', caption: 'My other button', img: 'w2ui-icon-check' }
        ],
        onClick: function (event) {
            switch (event.target) {
                case 'mybutton':
                    //business logic here
                    break;
            }
    },

How to execute w2ui delete event without warning message?


w2ui.grid.on('delete', function(event) {
    event.force = true;
    //console.log('No confirmation required');
});

OR

onDelete: function (event) {
        event.force = true;
...
}

Wednesday, 1 August 2018

How to add conditional style in w2ui grid to highlight individual cell?


Add following while preparing records array:

    'w2ui':{style: {
      10: ($(this).attr("ows_Column1")=="Approved")?"background-color: green":"red",
      11: ($(this).attr("ows_Column2")=="Approved")?"background-color: yellow":"",
      }}


To highlight specific header:

<style type="text/css">
td[col="6"].w2ui-head,td[col="7"].w2ui-head {
    border:dashed 2px #0099f8 !important;
    font-weight:bold;
}
</style>