@@ -435,6 +435,62 @@ DelRectangle {
435
435
__private .model = [... initModel];
436
436
}
437
437
438
+ function clear () {
439
+ __private .model = initModel = [];
440
+ __cellModel .clear ();
441
+ columns .forEach (
442
+ object => {
443
+ if (object .sortDirections && object .sortDirections .length !== 0 ) {
444
+ object .activeSorter = false ;
445
+ object .sortIndex = - 1 ;
446
+ object .sortMode = ' false' ;
447
+ }
448
+ if (object .hasOwnProperty (' onFilter' ) || object .hasOwnProperty (' filterInput' )) {
449
+ object .filterInput = ' ' ;
450
+ }
451
+ });
452
+ }
453
+
454
+ function appendRow (object ) {
455
+ __private .model .push (object);
456
+ __cellModel .appendRow ( __private .toCellObject (object));
457
+ }
458
+
459
+ function getRow (rowIndex ) {
460
+ if (rowIndex >= 0 && rowIndex < __private .model .length ) {
461
+ return __private .model [rowIndex];
462
+ }
463
+ return undefined ;
464
+ }
465
+
466
+ function insertRow (rowIndex , object ) {
467
+ __private .model .splice (rowIndex, 0 , object);
468
+ __cellModel .insertRow (rowIndex, __private .toCellObject (object));
469
+ }
470
+
471
+ function moveRow (fromRowIndex , toRowIndex , count = 1 ) {
472
+ if (fromRowIndex >= 0 && fromRowIndex < __private .model .length &&
473
+ toRowIndex >= 0 && toRowIndex < __private .model .length ) {
474
+ const objects = __private .model .splice (from, count);
475
+ __private .model .splice (to, 0 , ... objects);
476
+ __cellModel .moveRow (fromRowIndex, toRowIndex, count);
477
+ }
478
+ }
479
+
480
+ function removeRow (rowIndex , count = 1 ) {
481
+ if (rowIndex >= 0 && rowIndex < __private .model .length ) {
482
+ __private .model .splice (rowIndex, count);
483
+ __cellModel .removeRow (rowIndex, count);
484
+ }
485
+ }
486
+
487
+ function setRow (rowIndex , object ) {
488
+ if (rowIndex >= 0 && rowIndex < __private .model .length ) {
489
+ __private .model [rowIndex] = object;
490
+ __cellModel .setRow (rowIndex, __private .toCellObject (object));
491
+ }
492
+ }
493
+
438
494
component HoverIcon: DelIconText {
439
495
signal clicked ()
440
496
property alias hovered: __hoverHandler .hovered
@@ -523,6 +579,19 @@ DelRectangle {
523
579
control .checkedKeys = [... checkedKeysMap .keys ()];
524
580
}
525
581
582
+ function toCellObject (object ) {
583
+ let dataObject = new Object ;
584
+ for (let i = 0 ; i < control .columns .length ; i++ ) {
585
+ const dataIndex = control .columns [i].dataIndex ?? ' ' ;
586
+ if (object .hasOwnProperty (dataIndex)) {
587
+ dataObject[` __data${ i} ` ] = object[dataIndex];
588
+ } else {
589
+ dataObject[` __data${ i} ` ] = null ;
590
+ }
591
+ }
592
+ return dataObject;
593
+ }
594
+
526
595
onModelChanged: {
527
596
__cellView .contentY = 0 ;
528
597
__cellModel .clear ();
0 commit comments