Link Search Menu Expand Document

CSVDocument.KeyBreak Event

When key break is performed before or after the array data currently being focused on, if a value is specified for the BreakKey property (SpreadColumn.BreakKey property, etc.) of the object corresponding to the column by loading CSV data into the array object to be printed, the KeyBreak event will occur according to the following rules.The KeyBreak event does not occur for objects that do not have the BreakKey property or for classes that are not printed.

If the value of the BreakKey property is positive, compare the row of interest to the previous row before assigning it to an array element. If the result of the comparison is different, the row just before the assigned row is judged to be the key break.

If the value of the BreakKey property is negative, assign the row of interest to the array element and then compare it to the one row just before the assigned row. If the result of the comparison is different, the currently paying attention row is judged to be the key break.

If multiple items are determined to be keybreaks at the same time, the KeyBreak event will occur only for the object with the largest absolute value of the BreakKey property. If the values ​​of the BreakKey property are the same, the KeyBreak event will occur on the previously defined object (the leftmost column in the Spread class).

Example1

Item1
BreakKey = 1
Item2
BreakKey = 2
Item3
BreakKey = 3
1st line "AAA" "XXX" "111"
2nd line "AAA" "YYY" "111"
3rd line "BBB" "ZZZ" "222"
4th line "BBB" "ZZZ" "222"

In this example, the KeyBreak event occur as follows:

After setting the data in the first row to the array, the KeyBreak event occur at Item2[0]. After setting the data in the second row to the array, the KeyBreak event occur at Item3[1].

Example2

Item1
BreakKey = -1
Item2
BreakKey = -2
Item3
BreakKey = -3
1st line "AAA" "XXX" "111"
2nd line "AAA" "YYY" "111"
3rd line "BBB" "ZZZ" "222"
4th line "BBB" "ZZZ" "222"

In this example, the KeyBreak event occur as follows:

After setting the data in the second row to the array, the KeyBreak event occur at Item2[1]. After setting the data in the third row to the array, the KeyBreak event occur at Item3[2].

In the event handler triggered by the KeyBreak event, you can get the index value of the broken row by the CurrentIndex of the event object passed to the event handler. By assigning a new value to CurrentIndex, you can change the assignment position of subsequent data.

Example of advancing an insert line by one line

   Function OnKeyBreak(e) {
    e.CurrentIndex++;
    }

When the CurrentIndex is changed inside the event handler or the array object to be assigned CSV data is changed, the result is a sequence of data that becomes a key break condition in the subsequent assignment of CSV data. However, this operation does not raise the KeyBreak event. The key break decision is always based on the value of the original CSV data.

Example3

Function OnKeyBreak(e) {
    rec.insert(1);
    rec[e.CurrentIndex+1].item1 = "合計";
    rec[e.CurrentIndex+1].item2 = goukei;
    e.CurrentIndex++;
}
Item1
BreakKey = 1
Item2
BreakKey = 0
Item3
BreakKey = 0
1st line "AAA" "XXX" 111
2nd line "AAA" "YYY" 222
3rd line " Total " 333
4th line "BBB" "ZZZ" 555

In this example, the KeyBreak event that occurs in the second line of item1 executes the event handler shown in the above example and creates the third line. Subsequent CSV data creates the 4th line, and as the result, data changes in the 3rd and 4th lines of item1, but this change does not cause the KeyBreak event again.

Not supported in Mobile