Question

Real Time Detail Autonumbering

Is there a way to do a real time autonumbering to a detail?

 

Meaning, adding an index column to a detail and every time I delete or add a new product the index updates depending on the order and the place of the record in the detail table.

 

For example, If I have 3 products in the order page and I add a product in the middle between product 2 and 3, I would like that 3 number will be updated automatically to 4 and the new one will get number 3.

Like 1

Like

4 comments

Hello Raz,

 

The "Products" detail of the order edit page is a special detail that is hard to customize. I tried three different approaches and all of them failed. For example I tried creating a button on the detail, clicking which could trigger a custom method to update column values of the detail grid on the UI. Here is the example, but it's not working:

diff: /**SCHEMA_DIFF*/[
          {
		"operation": "insert",
		"name": "RefreshIndexesButton",
		"parentName": "Detail",
		"propertyName": "tools",
		"values": {
			"itemType": Terrasoft.ViewItemType.BUTTON,
			"style": this.Terrasoft.controls.ButtonEnums.style.Green,
			"caption": {bindTo: "Resources.Strings.ButtonCaption"},
			"click": { 
				"bindTo": "buttonClick" 
			}
		}
	}
        ]/**SCHEMA_DIFF*/,
 
.....
 
methods: {
          buttonClick: function(){
            var arr = this.getGridData().getItems();
            var counter=1;
            for (var i=0;i<arr.length;i++){
              this.set(arr[i].values["UsrPosition"],counter);
              counter++;
            }
          }
        },

The grid uses another method than "set" in the context of the function execution so as a result records are not being updated (the idea was to click the button upon adding a new record to the detail).

 

Your task cannot be achieved using standard application tools, but using additional development only. You can start with using the code I've already created and find a way to update all the column values for all the grid records. This is the only way to implement the functionality you need.

 

Best regards,

Oscar

Oscar Dylan,

Thank you very much for the detailed answer

Oscar Dylan,

Will it be the same approach for implementing this in a newly and custom detail?

Raz Guille Rosman,

 

Yes it should be so since the logic will be implemented on the detail schema and you can edit schemas for both newly created and custom details.

 

Best regards,

Oscar

Show all comments