Display and Edit Methods

Hi,
What is the difference between writing a display method under the Method node of Report or form and writing display method under design node at control level? And writing a display method at Table level?
Can anybody give me a real-time example? Is there any difference at runtime and performance wise and method calls?
Which is the better place to write Display method?
And also conform me in point of Edit and display methods. Which will show better performance? And How?
Best Regards,
Kishore

see this http://msdn.microsoft.com/en-us/library/aa595058.aspx

Display method is using for display purpose.As i know if you are writing the display method under form it will execute when the form is getting run.If you want to increase the performance of the display method need to add cache method.for example

Table_ds.cacheAddMethod(“method name”);

Thanks,

Saju.K

Hi Kranthi, Saju,

Thanks for fast reply.

Sorry if my query causes for any confusion.

I am aware of the web link which was provided by you. And also Table_ds.cacheAddMethod.

So my query is what is the difference between writing a display method under the Method node of Report or form and writing display method under design node at control level? And writing a display method at Table level?

What is the method calling and performance of display methods at different levels?

AND

We know that edit and display methods for display purpose. Using edit method we can update data into database.

So my question while fetching data from database how display method will fetch the data? How edit method will fetch the data and how normal field will fetch the data?

Which one performance good?

Advance thank for your suggestions.

Best Regards,

Krishna.

Edit methods

Edit methods are basically the same as display methods, except that users can also

write data to the fields. Instead of using the display modifier in the method header

you use the edit modifier. In addition, the first input variable should be of type

Boolean and called set. This variable will be set to true if the user changes the value

in the field in the form. The second input parameter should hold the value that the

user types in the field in the form.

This material is copyright and is licensed for the sole use by ALESSANDRO CAROLLO on 18th December

Chapter 4

[ 105 ]

To give an example of an edit method, we will create a new field in the CarTable to

hold the mileage of the car and have an edit method in RentalTable that enables the

users to be in the RentalTable form and still edit the field in CarTable.

We’ll create an extended data type of type integer for the new field and call it

Mileage. Then we’ll add the field to the CarTable.

The edit method in RentalTable will then look like this:

edit Mileage mileage(boolean set, Mileage value)

{

CarTable carTable;

Mileage ret;

;

carTable = CarTable::find(this.CarId, set);

if (set)

{

ttsbegin;

carTable.Mileage = value;

carTable.update();

ttscommit;

}

else

{

ret = carTable.Mileage;

}

return ret;

}

The first thing we do in this method is that we find the record in CarTable by

using the carId in the record that is selected in the form. If the field is edited, the set

parameter is true; we can use that parameter to decide if the record we select from

CarTable should be selected for update or not.

If the set variable is true we then tell the server to lock the record so that only

this process can update the record by using the ttsbegin statement. You will

learn more about manipulating data later in the book, so I won’t go into details

here, but the Mileage field in CarTable is set to be equal to the value that the

user entered in the RentalTable. The ttscommit will make sure that the record is

written to the database, and will also unlock the record so that it can be updated by

other processes.

If the set variable is false we simply return the mileage value from the selected

CarTable record.

Hi krishna,

Difference:

The edit method modifier is used to indicate that a method’s return value is to be displayed on a form, and users can edit that value. If you don’t want users to edit the value, use a display method.

Place- in context of code reusability.

According to me you create display method at Table leve so you can use that same method on form by specifying dataSource of that control to “table” & have that method at method property. same way you can use this method at report so its better to create this method at Table.

Regards,

Mehul

Hi krishna,

Difference:

The edit method modifier is used to indicate that a method’s return value is to be displayed on a form, and users can edit that value. If you don’t want users to edit the value, use a display method.

Place- in context of code reusability.

According to me you create display method at Table leve so you can use that same method on form by specifying dataSource of that control to “table” & have that method at method property. same way you can use this method at report so its better to create this method at Table.

Regards,

Mehul

It is always suggested to place the display or edit methods in table for better perfomrance. (if possible)

Fetching the data from the normal field will take less time than fetching data by using the methods.