@@ -819,8 +819,7 @@ export class PropertyGridModel {
819
819
currentlySelectedPanel : PanelModel ;
820
820
currentlySelectedPage : PageModel ;
821
821
public onSetNewObjectCallback : ( ) => void ;
822
-
823
- public objValueChangedCallback : ( ) => void ;
822
+ public onNewSurveyCreatedCallback : ( ) => void ;
824
823
public changedFromActionCallback : ( obj : Base , propertyName : string ) => void ;
825
824
public refresh ( ) : void {
826
825
this . setObj ( this . objValue ) ;
@@ -883,6 +882,9 @@ export class PropertyGridModel {
883
882
}
884
883
private setObj ( value : Base ) {
885
884
this . objValue = value ;
885
+ if ( this . onSetNewObjectCallback ) {
886
+ this . onSetNewObjectCallback ( ) ;
887
+ }
886
888
this . classNameProperty = ! ! this . obj
887
889
? PropertyJSONGenerator . getClassNameProperty ( this . obj )
888
890
: "" ;
@@ -893,24 +895,32 @@ export class PropertyGridModel {
893
895
this . titleActionsCreator = ! ! this . obj
894
896
? new PropertyGridTitleActionsCreator ( this . obj , this . options )
895
897
: undefined ;
896
- var json = this . getSurveyJSON ( ) ;
898
+ if ( ! this . surveyValue ) return ;
899
+ this . clearSurveyValue ( ) ;
900
+ this . createSurveyValue ( ) ;
901
+ }
902
+ private clearSurveyValue ( ) {
903
+ this . surveyValue . onValidateQuestion . clear ( ) ;
904
+ this . surveyValue . onValueChanging . clear ( ) ;
905
+ this . surveyValue . onValueChanged . clear ( ) ;
906
+ this . surveyValue . onMatrixCellValueChanging . clear ( ) ;
907
+ this . surveyValue . onMatrixCellValidate . clear ( ) ;
908
+ this . surveyValue . onMatrixCellValueChanged . clear ( ) ;
909
+ this . surveyValue . editingObj = undefined ;
910
+ this . surveyValue . data = { } ;
911
+ this . surveyValue . dispose ( ) ;
912
+ }
913
+ private createSurveyValue ( ) : void {
914
+ const json = this . getSurveyJSON ( ) ;
897
915
if ( this . options . readOnly ) {
898
916
json . mode = "display" ;
899
917
}
900
- if ( ! ! this . surveyValue ) {
901
- this . surveyValue . onValidateQuestion . clear ( ) ;
902
- this . surveyValue . onValueChanging . clear ( ) ;
903
- this . surveyValue . onValueChanged . clear ( ) ;
904
- this . surveyValue . onMatrixCellValueChanging . clear ( ) ;
905
- this . surveyValue . onMatrixCellValidate . clear ( ) ;
906
- this . surveyValue . onMatrixCellValueChanged . clear ( ) ;
907
- this . surveyValue . editingObj = undefined ;
908
- this . surveyValue . data = { } ;
909
- this . surveyValue . dispose ( ) ;
910
- }
911
918
this . surveyValue = this . createSurvey ( json , ( survey : SurveyModel ) : void => {
912
919
this . onCreateSurvey ( survey ) ;
913
920
} ) ;
921
+ if ( this . onNewSurveyCreatedCallback ) {
922
+ this . onNewSurveyCreatedCallback ( ) ;
923
+ }
914
924
if ( ! this . obj ) return ;
915
925
this . survey . onValueChanged . add ( ( sender , options ) => {
916
926
this . onValueChanged ( options ) ;
@@ -975,9 +985,6 @@ export class PropertyGridModel {
975
985
}
976
986
} ) ;
977
987
this . survey . editingObj = this . obj ;
978
- if ( this . objValueChangedCallback ) {
979
- this . objValueChangedCallback ( ) ;
980
- }
981
988
this . updateDependedPropertiesEditors ( ) ;
982
989
983
990
if ( this . showOneCategoryInPropertyGrid ) {
@@ -1082,6 +1089,9 @@ export class PropertyGridModel {
1082
1089
this . optionsValue = ! ! val ? val : new EmptySurveyCreatorOptions ( ) ;
1083
1090
}
1084
1091
public get survey ( ) {
1092
+ if ( ! this . surveyValue ) {
1093
+ this . createSurveyValue ( ) ;
1094
+ }
1085
1095
return this . surveyValue ;
1086
1096
}
1087
1097
public showOneCategoryInPropertyGrid : boolean = false ;
@@ -1124,6 +1134,7 @@ export class PropertyGridModel {
1124
1134
} ) ;
1125
1135
}
1126
1136
public expandCategoryIfNeeded ( ) : void {
1137
+ if ( ! this . surveyValue ) return ;
1127
1138
const expandedTabName = creatorSettings . propertyGrid . defaultExpandedTabName ;
1128
1139
if ( ! ! expandedTabName && ! this . getPropertyGridExpandedCategory ( ) ) {
1129
1140
const panel = < PanelModel > this . survey . getPanelByName ( expandedTabName ) ;
@@ -1218,9 +1229,6 @@ export class PropertyGridModel {
1218
1229
this . classNameValue !== options . value
1219
1230
) {
1220
1231
this . setObj ( this . obj ) ;
1221
- if ( this . onSetNewObjectCallback ) {
1222
- this . onSetNewObjectCallback ( ) ;
1223
- }
1224
1232
if ( ! ! this . survey ) {
1225
1233
const question = this . survey . getQuestionByName ( options . name ) ;
1226
1234
if ( ! ! question ) {
0 commit comments