I am adding progressbar to each row of my first grid's banded tableview column !
The way I do it => I put 4 progressbars on my form and on
btvArrProgGetProperties(TcxCustomGridTableItem *Sender, TcxCustomGridRecord *ARecord,
TcxCustomEditProperties *&AProperties) assigning properties to a specific row by changing putted progressbar properties.
here is my code
void __fastcall TfMain::btvArrProgGetProperties(TcxCustomGridTableItem *Sender, TcxCustomGridRecord *ARecord,
TcxCustomEditProperties *&AProperties)
{
if ( StrToInt(ARecord->Values[ARecord->RecordIndex,1])==4 ){
ARecord->Values[ARecord->RecordIndex,0]=100;
AProperties=pCancel->Properties;
}
else
if ( StrToInt(ARecord->Values[ARecord->RecordIndex,1])==2) {
ARecord->Values[ARecord->RecordIndex,0]=100;
AProperties=pDep->Properties;
}
else {
if (StrToInt(ARecord->Values[ARecord->RecordIndex,1])==1) {
if ((ARecord->Values[ARecord->RecordIndex,7])!=0 && (ARecord->Values[ARecord->RecordIndex,12])!=0) {
//now time
nwTm=Now().FormatString("hh:mm:ss");
//get dep time
dpTm=StrToDateTime(ARecord->Values[ARecord->RecordIndex,7]);
dpTm.DecodeTime(&dpH,&dpM,&dpS,&dpMS);
//get reg time
rgTm=StrToDateTime(ARecord->Values[ARecord->RecordIndex,12]);
//find difference between dep and reg
dif=(1.0 + Double(dpTm)-Double(rgTm));
//get difference hours and mins
dif.DecodeTime(&difH,&difM,&difS,&difMS);
//diff between dep and reg in seconds
pReg->Properties->Max=difH*3600+difM*60+difS;
nwTm=Now().FormatString("hh:mm:ss");
nwTm.DecodeTime(&nwH,&nwM,&nwS,&nwMS);
if ((dpH>nwH) || ((dpH>nwH) && (dpM>=nwM ||dpM<=nwM)) || (dpH==nwH && dpM>nwM) ) {
fltRem =(1.0 + Double(dpTm)-Double(nwTm));
fltRem.DecodeTime(&remH,&remM,&remS,&remMS);
_result=remH*3600+remM*60+remS;
pReg->Properties->Text=getTimeBySecs(_result);
ARecord->Values[ARecord->RecordIndex,0]=pReg->Properties->Max-_result;
pReg->Position=- _result;
}
else
{
pReg->Properties->Max=100;
ARecord->Values[ARecord->RecordIndex,0]=100;
pReg->Properties->Text="Готово";
/*
ARecord->Values[ARecord->RecordIndex,0]=pReg->Properties->Max;
pReg->Position=pReg->Properties->Max;
*/
}
AProperties=pReg->Properties;
}
}
}
}
I think that this not a good approach to solve my problem (adding progressbar to a column which it's position get's changed dynamically), because when I click to each's row progressbar's position gets changed due to a last value set to progressbar!!
I prefer to dynamically create progressbar set name and other properties to it during runtime and assign to specific row on GetProperties event.
What approach is the best one ?
Is there any demo on this issue? If yes could you share please!
Thanks in advance !
Related
So i'm trying to colorize form lines with different colors. if i check current.PrimaryTransportation checkbox in one line and all i get is one big yellow grid
the code i'm using looks like this:
public void displayOption(Common _record, FormRowDisplayOption _options)
{
SIS_ResourcesTmp buffer = _record;
SIS_ResourceSum current = SIS_ResourceSum_DS.cursor();
#define.grey(12895428)
#define.white(16448250)
#define.yellow(3927039)
;
_options.backColor(#grey);
if (!current.VendorPrice && !current.UnitConvertRate) {
if (!current.UnitConvertToTons && !current.DistanceVendorToObject && current.PrimaryTransportation) {
_options.backColor(#yellow);
}
} else {
_options.backColor(#white);
}
SIS_ResourcesTmp_ds.refresh();
}
Use the parameter _record to check whether to set the color for the current row to yellow or not.
This depends on your scenario but I think you need one more else conditon for the nested if statement. Or I would rather try to eliminate the nested if like this:
if (!current.VendPrice &&
!current.UnitConvertRate &&
!current.UnitConvertToTons &&
current.PrimaryTransportation)
{
_options.backColor(#yellow);
}
else
{
_options.backColor(#white);
}
Is there a way to know if a scroll bar is present on a table view? (Other than what I did in my code below)
My goal is to position 2 arrow images (to close/open a side panel) on the right side of a table (over the table.). But I don't want to put them over the scroll bar.
The table content is a result of a search, so sometime the scroll bar is visible and other time it is not. If there is not enough items.
I want the position of my arrows to change every time the tableview items change.
I already try the following solution, but the result is that the arrows are moved the second time I do the search. Looks like a concurrency problem. Like if my listener code is executed before the table is rendered.
Is there a way to solve that?
tableView.getItems().addListener( (ListChangeListener<LogData>) c -> {
// Check if scroll bar is visible on the table
// And if yes, move the arrow images to not be over the scroll bar
Double lScrollBarWidth = null;
Set<Node> nodes = tableView.lookupAll( ".scroll-bar" );
for ( final Node node : nodes )
{
if ( node instanceof ScrollBar )
{
ScrollBar sb = (ScrollBar) node;
if ( sb.getOrientation() == Orientation.VERTICAL )
{
LOGGER.debug( "Scroll bar visible : {}", sb.isVisible() );
if ( sb.isVisible() )
{
lScrollBarWidth = sb.getWidth();
}
}
}
}
if ( lLogDataList.size() > 0 && lScrollBarWidth != null )
{
LOGGER.debug( "Must move the arrows images" );
tableViewController.setArrowsDistanceFromRightTo( lScrollBarWidth );
}
else
{
tableViewController.setArrowsDistanceFromRightTo( 0d );
}} );
I assume you know that it is not a good idea to rely on the internal implementation of TableView. Having said that, you're code looks mostly good (I did a similar thing for an infinite scrolling example).
However you should also consider the case that the scrollbar may appear due to the main window changing its size.
I would therefore suggest you listen to changes in the visibilty-property of the scrollbar.
private ScrollBar getVerticalScrollbar() {
ScrollBar result = null;
for (Node n : table.lookupAll(".scroll-bar")) {
if (n instanceof ScrollBar) {
ScrollBar bar = (ScrollBar) n;
if (bar.getOrientation().equals(Orientation.VERTICAL)) {
result = bar;
}
}
}
return result;
}
...
bar.visibleProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
// tableViewController.setArrowsDistanceFromRightTo(...)
}
);
Rather than create events for Christmas and Easter and the like, I'd like to be able colour the date cells affected, and even perhaps have a grey translucent text for each event. Is there any easy way to do this in FullCalendar?
EDIT
It's been pointed out to me that fc-state-highlight is used to highlight fc-today, so perhaps a similar thing could be done, applying a css class to cells and defining it as "public holiday colour". A thought. The problem is how does one apply this class to the relevant dates such that it works within FC without breaking anything.
This could be done using eventAfterAllRender. Make a separate ajax call to find all of the holidays then change the color of the td. Example for month and holiday being June 1st, done with FC 2.0.1: http://jsfiddle.net/marcrazyness/C8jpm
eventAfterAllRender: function (view) {
//Use view.intervalStart and view.intervalEnd to find date range of holidays
//Make ajax call to find holidays in range.
var fourthOfJuly = moment('2014-07-04','YYYY-MM-DD');
var holidays = [fourthOfJuly];
var holidayMoment;
for(var i = 0; i < holidays.length; i++) {
holidayMoment = holidays[i];
if (view.name == 'month') {
$("td[data-date=" + holidayMoment.format('YYYY-MM-DD') + "]").addClass('holiday');
} else if (view.name =='agendaWeek') {
var classNames = $("th:contains(' " + holidayMoment.format('M/D') + "')").attr("class");
if (classNames != null) {
var classNamesArray = classNames.split(" ");
for(var i = 0; i < classNamesArray.length; i++) {
if(classNamesArray[i].indexOf('fc-col') > -1) {
$("td." + classNamesArray[i]).addClass('holiday');
break;
}
}
}
} else if (view.name == 'agendaDay') {
if(holidayMoment.format('YYYY-MM-DD') == $('#calendar').fullCalendar('getDate').format('YYYY-MM-DD')) {
$("td.fc-col0").addClass('holiday');
};
}
}
}
when doc ready, have a js function to select all TDs, with data-date the ones you want, and add CSS class to them. I don't know if it works, just an idea.
I am trying to display some aggregate value (like total) in the last row of an ng-grid. The style and css class of the last row needs to be different than the other cells in that column. How to acheive this?
The cellTemplate in a column definition applies to all cells in that column, but in my case I need to have a different style for the last row in that column. Can anyone please suggest me a solution.
Thanks
Sudipta
I was able to add a class to the last row through a plugin:
function ngGridAddClassToLastRow(className) {
var self = this;
self.grid = null;
self.scope = null;
self.init = function (scope, grid, services) {
self.domUtilityService = services.DomUtilityService;
self.grid = grid;
self.scope = scope;
var addClass = function () {
var lastRow = self.scope.renderedRows[self.scope.renderedRows.length - 1];
lastRow.elm[0].className = lastRow.elm[0].className + ' ' + className;
};
self.scope.$watch(grid.config.data, addClass);
};
}
And with this added to the gridOptions:
...
plugins: [new ngGridAddClassToLastRow('<some class name>'),
...
And of course add some css, e.g. in my case:
.lastRow {
border-bottom: 0px;
}
That worked for me. I cannot say for certain that is the way to go since, needless to say, i'm a noob with Angular and ngGrid. I've constructed the plugin from flexible height plugin.
You can set a special property "isLast" (or however you like to name it) of the item that should be displayed in the last row. This item can be accessed through row.entity.isLast.
... somewhere in your controller ....
$scope.getRowClass = function(row) {
return row.entity.isLast === true ? 'lastRow' : '';
}
... somewhere inside the gridOptions ...
rowTemplate: '<div ng-style="{ \'cursor\': row.cursor }" ng-repeat="col in renderedColumns" ng-class="[col.colIndex(), getRowClass(row)]" class="ngCell {{col.cellClass}}">....</div>'
Based on the .lastRow class you could define a custom style for the last grid row.
Is there any way of making a single row within an AspxGridView flash different colours based on a value within a cell. E.g. continually changing the background colour of the row between red and green if a value in a cell is 5 so that it stands out on the page?
I have found one article that says it cant be done, but this was in 2008..
http://www.devexpress.com/Support/Center/p/Q135996.aspx
With a css class added to row as advised in the previous answer you can apply following script and style:
$(function () {
setInterval(flashRow, 500);
});
function flashRow() {
$("tr.blink").toggleClass("red");
}
Css style:
tr.blink
{
background-color: Green;
}
tr.red
{
background-color: Red;
}
Where blink - css style that you add to the row in the RowDataBound method.
See demo here
Take a look at the E3324 Code Central example.
You can use the described approach as a starting point.
<dx:ASPxTimer ID="ASPxTimer2" runat="server" Interval="250"
ClientSideEvents-Tick="function(s,e)
{
var table = document.getElementById(gridUsers.name);
for (i = 0; i <= table.rows.length; i++)
{
var tableRow = document.getElementById(gridUsers.name + '_DXDataRow' + i);
if (tableRow.getAttribute('flicker') != '1')
return;
if (tableRow.style.backgroundColor == '' || tableRow.style.backgroundColor == 'white')
tableRow.style.backgroundColor = 'red';
else
tableRow.style.backgroundColor = 'white';
}
}">
</dx:ASPxTimer>
you can do that on the event rowdatabount
check the current row is it with the value you want to highlight
then change the color of the current row by adding css attributes to it or assigning a cssclass