Several functions UniDBGrid control optimization

Content Wrap

UniDBGrid default content within the cell exceeds the table if the column width does not automatically adjust row height and wrap, great inconvenience to the customer, can be achieved by modifying the properties of ServerModule CustomCSS.

<style type="text/css">

.x-grid-cell-inner {

  white-space: initial;

}</style>

Hover display field

If a form field content is too long, you want to achieve when you move the mouse to display the contents of the field above the field to prompt the form, you can set the table corresponding field ShowToolTip properties achieved after the query execution.

UniDBGrid1.Columns.Items[0].ShowToolTip:=true;

Bottom of the table displays the current record number and the total number of records
         in UniDBGrid of ClientEvents-> UniEvents property, select Ext.toolbar.Paging, add pagingBar.beforeInit event, and then after running the table on the right bottom of the table you'll find the "Display 1- 10, a total of 120. "

function pagingBar.beforeInit(sender, config)

{

config.displayInfo = true;

}

Automatically set the column width

The open UniDBGrid ClientEvents-> ExtEvents property selected Ext.data.Store page store.load double-click event, add the following code to achieve automatic adjustment of each column of the table according to the length of the longest column width field:

function store.load(sender, records, successful, operation, eOpts)

{

  sender.grid.columnManager.columns.forEach(function(col){col.autoSize()})

}

Lock a column in a row        

If UniDBGrid ReadOnly property to False, then double-click on a CELL allowed to edit their content, if you want to make a specific row and column are not allowed to edit, open UniDBGrid of ClientEvents-> ExtEvents property, select Ext.grid.Panel page, Double-click its beforeedit event, add the following code:

function beforeedit(editor, context, eOpts)

{

  was FixedRow, FixedCol;

  FixedRow = 3;

  FixedCol = 3;  

  if (editor.cmp.uniRow < FixedRow || editor.cmp.uniCol < FixedCol)

{

     return false;

       }

}

         The above code will effect locking the first three rows and three columns not double-click to enter edit mode table, other affected areas. However, testing found that, if the UniDBGrid Options-> dgRowSelect property is true, the method will fail.

Gets points in the field of content
open UniDBGrid of ClientEvents-> ExtEvents property, select Ext.grid.Panel page, double-click its celledit event, add the following code:

function cellclick(sender, td, cellIndex, record, tr, rowIndex, e, eOpts)

{

alert(sender.store.getAt(rowIndex).get(cellIndex));

}

         This code enables the display CELL mouse clicks. However, the test found that if UniDBGrid set Options-> dgRowSelect and dgRowNumbers attributes, cellindex minus the number of columns corresponding to these properties lead to new settings, such as setting the table dgRowSelect property, the first column of the table is checked block, an occupied, alert (sender.store.getAt (rowIndex) .get (cellIndex));

It should be written as

alert(sender.store.getAt(rowIndex).get(cellIndex-1));

And wherein the line for interlaced discoloration discoloration

Sometimes need to form odd and even lines show a different background color, sometimes need to set the background color based on the characteristics of its record value of a field, double-click UniDBGrid of OnDrawColumnCell add an event:

procedure TUniFrame1.UniDBGrid1DrawColumnCell(Sender: TObject; ACol,

  ARow: Integer; Column: TUniDBGridColumn; Attribs: TUniCellAttribs);

begin

if Column.Field.DataSet.RecNo mod 2=0 then

  begin

    Attribs.Color:=clBlue;

  end

else

  begin

    Attribs.Color:=clRed;

  end;

if Column.Field.DataSet.FieldByName ( 'passport number') .AsString = 'HZ002' then

  begin

    Attribs.Color:=clYellow;

  end;

End;
----------------
Disclaimer: This article is CSDN blogger "road at the foot []" of the original article, follow the CC 4.0 BY-SA copyright agreements, please attach a reprint the original source link and this statement.
Original link: https: //blog.csdn.net/dlboy2018/article/details/103544149

Guess you like

Origin www.cnblogs.com/AkumaIII/p/12052475.html