//TH-Header //***************************************************************************************** // Copyright (c) 2020 PP7 // All rights reserved. // // $FileName : csfWebColumn.pkg // $ProjectName : PP7 SyncFusion // $Authors : Wil van Antwerpen // $Created : 06.04.2020 13:46 // // Contents: // This is a web framework wrapper class for the SyncFusion Grid control. // Documentation for the API is here: // https://helpej2.syncfusion.com/documentation/api/grid/columnModel/ // //***************************************************************************************** //TH-RevisionStart // ******************** // MODIFICATION SUMMARY // ******************** // ####### DD/MM/YYYY WHO COMMENT //TH-RevisionEnd Use cWebForm.pkg Use csfWebList.h Use tWebRow.pkg Use csfWebColumn_Mixin.pkg { OverrideProperty=pbFillHeight Visibility=Private } { OverrideProperty=psLabel Visibility=Private } { OverrideProperty=psLabelColor Visibility=Private } { OverrideProperty=peLabelAlign Visibility=Private } { OverrideProperty=peLabelPosition Visibility=Private } { OverrideProperty=piLabelOffset Visibility=Private } { OverrideProperty=pbShowLabel Visibility=Private } { OverrideProperty=piColumnIndex Visibility=Private } { OverrideProperty=piColumnSpan Visibility=Private } { OverrideProperty=pbIsWebColumn Visibility=Private } { HelpTopic=cWebColumn } { DesignerJSClass=df.WebColumn } Class csfWebColumn Is a cWebForm Procedure Construct_Object tsfWebColumnCustomDraw CustomDraw Forward Send Construct_Object { DesignTime=False } Property Integer piColumnId -1 // will be assigned when the grid is registered below { DesignTime=False } Property Integer piColumnAggregateId -1 // Column aggregate if defined Send Define_csfWebColumn_Mixin Property Integer piMinWidth { WebProperty=Client } Property Integer piWidth Property Integer piMaxWidth Property String psTemplate { EnumList="Left, Right, Center, Justify" } { InitialValue="Left" } { WebProperty=Client } Property String psTextAlign { EnumList="none, string, number, boolean, date, dateTime, checkBox" } { InitialValue="" } Property String psType { WebProperty=Client } Property Boolean pbShowColumnMenu True { WebProperty=Client } Property Boolean pbShowInColumnChooser True Property Boolean pbAllowGrouping True Property Boolean pbAllowReordering True Property Boolean pbAllowResizing True Property Boolean pbAllowSearching True Property Boolean pbAllowSorting True { WebProperty=Client } Property Boolean pbAutoFit False { EnumList="Clip, Ellipsis, EllipsisWithTooltip" } { InitialValue="Ellipsis" } Property String psClipMode "Ellipsis" // If disableHtmlEncode is set to true, it encodes the HTML of the header and content cells. Property Boolean pbDisableHtmlEncode True // If displayAsCheckBox is set to true, it displays the column value as a check box instead of Boolean value. Property Boolean pbDisplayAsCheckBox False Property Boolean pbEnableGroupByFormat True // // // see also: // https://helpej2.syncfusion.com/documentation/common/internationalization#manipulating-numbers { EnumList="C0, C2, P0, P2, N0, N2" } { InitialValue="" } { WebProperty=Client } Property String psFormat "" // psCaption is HeaderText in the SyncFusion control, we had to use psCaption here // so that it works OK in the webapp designer. { WebProperty=Client } Property String psCaption "" Property String psHeaderTemplate "" { EnumList="Left, Right, Center, Justify" } { InitialValue="" } { WebProperty=Client } Property String psHeaderTextAlign "" { WebProperty=Client } Property tsfWebColumnCustomDraw pCustomDraw // We set this to false, so we can detect if a DAW webcolumn was dropped // as it will have this set to true. Property Boolean pbIsWebColumn False // Set psJSClass To "sf.WebColumn" // Initialize custom draw with "no custom draw" Move False To CustomDraw.bHasHtml Set pCustomDraw to CustomDraw { WebProperty=Client } Property Boolean pbZeroSuppress False // Default is to use the grid settings for zero suppress Property Boolean pbUseGridZeroSuppress True // Totals Property String psTotalType Property String psTotalFormat Property String psFooterTemplate Property String psGroupFooterTemplate Property Number pnTotalValue // Date/Time Property String psDateFormat //"yMd" = 5/22/2020 Property String psTimeFormat //"h:mm tt" = 8:00 am End_Procedure Import_Class_Protocol csfWebColumn_Mixin Function ColumnFormat Returns String Integer iFile iField iType iPrecision String sFormat Get psFormat to sFormat If (sFormat="") Begin Get Data_File to iFile Get Data_Field to iField If ((iFile<>0)and(iField<>0)) Begin Get_Attribute DF_FIELD_TYPE of iFile iField to iType If (iType=DF_BCD) Begin Get_Attribute DF_FIELD_PRECISION of iFile iField to iPrecision Move "N2" to sFormat If (iPrecision=0) Begin Move "N0" to sFormat End Set piPrecision to iPrecision End End End Function_Return sFormat End_Function Function FooterTemplate Returns String String sType Get psTotalType to sType If (sType="Sum") ; Function_Return "${Sum}" If (sType="Average") ; Function_Return "${Average}" If (sType="Min") ; Function_Return "${Min}" If (sType="Max") ; Function_Return "${Max}" If (sType="Count") ; Function_Return "${Count}" If (sType="Truecount") ; Function_Return "${Truecount}" If (sType="Falsecount") ; Function_Return "${Falsecount}" Function_Return "" End_Function Function LoadWebColumnProperties Returns tsfWebColumn tsfWebColumn Column Boolean bZeroSuppress Integer iFile iField iType iPrecision String sTextAlign sHeaderTextAlign String sDataType sFormat Get Data_File to iFile Get Data_Field to iField // Get ColumnFormat to sFormat Get psTextAlign to sTextAlign Get psHeaderTextAlign to sHeaderTextAlign Get psType to sDataType If ((iFile<>0) and (iField<>0)) Begin Get_Attribute DF_FIELD_TYPE of iFile iField to iType Get_Attribute DF_FIELD_PRECISION of iFile iField to iPrecision If (iType=DF_BCD) Begin If (sDataType="") ; Move "number" to sDataType If (sTextAlign="") ; Move "Right" to sTextAlign If (sHeaderTextAlign="") ; Move "Right" to sHeaderTextAlign End End // Move sTextAlign to Column.sTextAlign Move sHeaderTextAlign to Column.sHeaderTextAlign Move sFormat to Column.sFormat Move sDataType to Column.sType // Get psField to Column.sField Get psCaption to Column.sHeaderText Get psHeaderTemplate to Column.sHeaderTemplate Get piMinWidth to Column.iMinWidth Get piWidth to Column.iWidth Get piMaxWidth to Column.iMaxWidth Get psTemplate to Column.sTemplate Get pbShowColumnMenu to Column.bShowColumnMenu Get pbShowInColumnChooser to Column.bShowInColumnChooser Get pbAllowGrouping to Column.bAllowGrouping Get pbAllowReordering to Column.bAllowReordering Get pbAllowResizing to Column.bAllowResizing Get pbAllowSearching to Column.bAllowSearching Get pbAllowSorting to Column.bAllowSorting Get pbAutoFit to Column.bAutoFit Get psClipMode to Column.sClipMode Get pbDisableHtmlEncode to Column.bDisableHtmlEncode Get pbDisplayAsCheckBox to Column.bDisplayAsCheckBox Get pbEnableGroupByFormat to Column.bEnableGroupByFormat Get pbVisible to Column.bVisible If (pbUseGridZeroSuppress(Self)) Begin Delegate Get pbZeroSuppress to bZeroSuppress Set pbZeroSuppress to bZeroSuppress End Function_Return Column End_Function // By SVN -- fix to avoid conflict in between DAW JS FW and CLDR data Procedure Attach_Deo_To_Server String sMask String sFormat Get psMask to sMask Get psFormat to sFormat Forward Send Attach_Deo_To_Server If (sFormat<>"") Begin Set psMask to sMask End End_Procedure // By SVN -- This is temporary solution as pbRender is not implemented Procedure Set pbRender Boolean value Set pbVisible to value End_Procedure Function pbRender Returns Boolean Function_Return (pbVisible(Self)) End_Function Procedure Set peAlign Integer eAlign If (eAlign=alignLeft) Begin Set psTextAlign to "Left" Set psHeaderTextAlign to "Left" End If (eAlign=alignCenter) Begin Set psTextAlign to "Center" Set psHeaderTextAlign to "Center" End If (eAlign=alignRight) Begin Set psTextAlign to "Right" Set psHeaderTextAlign to "Right" End End_Procedure Function peAlign Returns Integer String sAlign Get psTextAlign to sAlign If (sAlign="Center") ; Function_Return alignCenter If (sAlign="Right") ; Function_Return alignRight Function_Return alignLeft End_Function Function LocalDateFormat Returns String Integer iDateFormat iDateSep String sTemp Get psDateFormat to sTemp If (sTemp<>"") ; Function_Return sTemp Get_Attribute DF_DATE_FORMAT to iDateFormat Get_Attribute DF_DATE_SEPARATOR to iDateSep Move (Character(iDateSep)) to sTemp If (iDateFormat = DF_DATE_USA) ; Function_Return "yMd" Else If (iDateFormat = DF_DATE_EUROPEAN) ; Function_Return ("dd"+sTemp+"MM"+sTemp+"yyyy") Function_Return ("yyyy"+sTemp+"MM"+sTemp+"dd") End_Function Function LocalTimeFormat Returns String Integer iDateFormat iDateSep String sTemp Get psTimeFormat to sTemp If (sTemp<>"") ; Function_Return sTemp Get_Attribute DF_DATE_FORMAT to iDateFormat If (iDateFormat = DF_DATE_USA) ; Function_Return "h:mm tt" Function_Return "HH:mm:ss" End_Function // "none, string, number, boolean, date, dateTime, checkBox" Procedure Set peDataType Integer iDataType Forward Set peDataType to iDataType If (iDataType=typeASCII) Begin End If (iDataType=typeNumber) Begin Set psType to "number" End If (iDataType=typeDate) Begin Set psType to "date" Set psFormat to (LocalDateFormat(Self)) End If (iDataType=typeDateTime) Begin Set psType to "dateTime" Set psFormat to (LocalDateFormat(Self) * LocalTimeFormat(Self)) End If (iDataType=typeTime) Begin End End_Procedure Function IsHtmlColumn Returns Boolean Function_Return false End_Function // Connect javascript part // // The columns have been setup here, but no data has been sent to the // client yet. // Procedure ConnectColumn String sField String[] aParams Get psField To sField Move sField To aParams[0] Send ClientAction "connectColumn" aParams End_Procedure Procedure OnDefineTooltip String ByRef sToolTip End_Procedure Procedure OnDefineCssClass String ByRef sCss End_Procedure Function CreateJSDate String sDate Boolean bDateTime Returns String Date dDate DateTime dtDate String sY sM sD sTH sTM sTS If (sDate="") Begin Function_Return "" End Move sDate to dDate If (bDateTime) Begin Move sDate to dtDate End Move (DateGetYear(dDate)) to sY Move (DateGetMonth(dDate)) to sM Move (DateGetDay(dDate)) to sD Move "00" to sTH Move "00" to sTM Move "00" to sTS If (bDateTime) Begin Move (DateGetHour(dtDate)) to sTH Move (DateGetMinute(dtDate)) to sTM Move (DateGetSecond(dtDate)) to sTS If (Length(sTH)=1) Begin Move ('0'+sTH) to sTH End If (Length(sTM)=1) Begin Move ('0'+sTM) to sTM End If (Length(sTS)=1) Begin Move ('0'+sTS) to sTS End End If (Length(sM)=1) Begin Move ('0'+sM) to sM End If (Length(sD)=1) Begin Move ('0'+sD) to sD End // YYYY-MM-DDTHH:MM:SS.msZ // 0000-00-00T00:00:00.000Z Function_Return (sY+'-'+sM+'-'+sD +"T"+sTH+":"+sTM+":"+sTS+".000Z") End_Function // Called by the list / grid to determine the field value details based on the current // environment values (global buffer or properties). It fills the tWebCell struct that is // passed by reference with details needed by the JavaScript Engine to render the cell. Procedure LoadGridCell tWebCell ByRef tCell Integer iFile iField iDataType String sValue sAggregate Number nTotal Get Data_File to iFile Get Data_Field to iField Get peDataType to iDataType Get pnTotalValue to nTotal Delegate Get AggregateType (psField(Self)) to sAggregate If (iFile <> 0) Begin // If there is a data binding then get the file.field value.... Get_Field_Value iFile iField to sValue End Else Begin Send OnSetCalculatedValue (&sValue) // calculated value End //// Convert the value into the correct format for transport.... Move (Rtrim(sValue)) to sValue // make sure the value is trimmed // Average, Truecount, Falsecount are not supported // These totals are used for the Custom running totals calculations If (iDataType=typeNumber) Begin If (sAggregate="Sum") Begin Move (nTotal + Number(sValue)) to nTotal End If (sAggregate="Min") Begin If (Number(sValue)nTotal) Move (Number(sValue)) to nTotal End End If (sAggregate="Count") Begin Move (nTotal + 1) to nTotal End If (iDataType=typeDate) Begin Get CreateJSDate sValue False to sValue End If (iDataType=typeDateTime) Begin Get CreateJSDate sValue True to sValue End Set pnTotalValue to nTotal // Give a chance to add custom tooltips & CSS Classnames Send OnDefineTooltip (&tCell.sTooltip) Send OnDefineCssClass (&tCell.sCssClassName) Move sValue to tCell.sValue End_Procedure Procedure Set Total String sType String sFormat String sTemplate Set psTotalType to sType If (num_arguments>1) Begin If (sFormat<>"") ; Set psTotalFormat to sFormat End If (num_arguments>2) Begin Set psFooterTemplate to sTemplate Set psGroupFooterTemplate to sTemplate End End_Procedure Procedure BuildAggregate Handle hoAggregate Integer iAggregateID String sTemplate sGroupTemplate sFormat tsfWebColumnAggregate[] Aggregates If (psTotalType(Self)<>"") Begin // Templates Get psFooterTemplate to sTemplate If (sTemplate="") ; Get FooterTemplate to sTemplate Move sTemplate to sGroupTemplate // In case percent value passed, clear Group template If (Pos("%", sGroupTemplate)) ; Move "-" to sGroupTemplate // Formats Get psTotalFormat to sFormat If (sFormat="") ; Get ColumnFormat to sFormat // Get Create (RefClass(csfWebColumnAggregate)) to hoAggregate If (hoAggregate) Begin Delegate Get pColumnAggregates to Aggregates Get piAggregateId of hoAggregate to iAggregateID Get psTotalType to Aggregates[iAggregateID].sType Get psField to Aggregates[iAggregateID].sField Move sFormat to Aggregates[iAggregateID].sFormat Move sTemplate to Aggregates[iAggregateID].sFooterTemplate Move sGroupTemplate to Aggregates[iAggregateID].sGroupFooterTemplate Delegate Set pColumnAggregates to Aggregates Set piColumnAggregateId to iAggregateID End End End_Procedure Procedure End_Construct_Object Forward Send End_Construct_Object Send BuildColumnID Send BuildAggregate Delegate Send RegisterColumn Self End_Procedure End_Class // NOTES: Grid Cells Formatting //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.