관리 메뉴

드럼치는 프로그래머

[jQuery] jqGrid row vertical alignment not middle 본문

★─Programing/☆─WebProgram

[jQuery] jqGrid row vertical alignment not middle

드럼치는한동이 2016. 8. 3. 09:40

For some reason on our grid the vertical alignment of the rows is not middle. It appears to be top. Is there something specific you have to do to achieve vertical alignment?

Here's an example of the alignment:

 

Our grid definitions:

$.extend(jQuery.jgrid.defaults, { 
    url:'NoData.json',
    datatype: 'json',
    mtype: 'GET',
    altRows:true, 
    //altclass:'zebraOdd',
    loadError: function(xhr,st,err) { 
        handleError(xhr, 'Error loading grid');
    },
    onPaging: function (b) {
        return onPage($(this));
    },
    beforeRequest: function() {
        beforeReq($(this));
    },
    loadComplete: function() {
        loadComp($(this));
    },
    onSelectRow: function(id){
        $(this).resetSelection(); //This prevents the disabling of the row hovering and altclass - http://stackoverflow.com/questions/3916477
    },
    scrollOffset:0, //No scrollbar
    rowNum:15,
    shrinkToFit:true,
    width:1120,
    viewrecords: true ,
    height: '360',
    hidegrid: false //Don't show the expand/collapse button on the top right
});  

$("#grid-pos").jqGrid({
    colNames:['Position Account', 'Product Code', 'Product Type','Expiry', 'Put/Call', 'Strike Price', 'Current Long', 'Current Short', 'Held Exercise Requests', 'Held Abandon Requests', 'Last Trade Date / Expiration Date', 'Select Operation'],
    colModel :[
                   {name:'account', index:'account', width:85, sortable:false},
                   {name:'productCode', index:'productCode', width:85, sortable:false},
                   {name:'productType', index:'productType', width:85, sortable:false},
                   {name:'expiry', index:'expiry', width:85, align:'right',stype:'select', sortable:false},
                   {name:'putCall', index:'putCall', width:85, sortable:false},
                   {name:'strike', index:'strike', sorttype: 'float', align:'right', width:85, sortable:false},
                   {name:'long', index:'long', width:85, align:'right', sortable:false},
                   {name:'short', index:'short', width:85, align:'right', sortable:false},  
                   {name:'exercise', index:'exercise', width:90, align:'right', sortable:false},
                   {name:'abandon', index:'abandon', width:90, align:'right', sortable:false},
                   {name:'LTD', index:'LTD', width:110, align:'right', sortable:false},
                   {index:'operations', width:150, title:false, align: 'center', formatter:opsFormatter, sortable:false}
               ],
               pager: '#div-pos-pager',
               caption: 'View Positions'
});  

 

Answers

 

Have you tried applying vertical-align: middle; css property to your table cells?

I believe default vertical alignment is top so applying the above should override that. Also if you can give me a link to an example page that shows this I can look into it further.

 

This will make it middle-align. Change it from middle to top or bottom if you have other needs.

<style type="text/css">
.ui-jqgrid tr.jqgrow td {vertical-align:middle !important}
</style>
<style>
    .ui-jqgrid tr.jqgrow { outline-style: none; color:#286abf;font-weight:normal; cursor : pointer; vertical-align:top }
</style>

 

[출처] http://stackoverflow.com/questions/4148469/jqgrid-row-vertical-alignment-not-middle

Comments