Dictionary

The dictionary component is used to display all the words in a dictionary with the option to add new words or delete existing words from the dictionary.

Dictionaries user control

Component Code

The first section of the code includes the standard parameter set and all the variables needed for the component. Below are the methods used for this component.

ReadItems(GridReadEventArgs args)

This is the method that’s called when any CUD (Create, Update, Delete) operation is performed on the grid. This allows us to have more control over the grid by performing manual data source operations.

This method is used to capture the Request from the GridReadEventArgs object then call GetData().

The Data and Total properties of the grid are then updated.

Follow this link to view Telerik’s official documentation that dives into the lower-level functions of the OnRead event and the different CUD operations.

GetData()

This method is responsible for calling the database and getting the required data for the grid.

At a high level, this method first called the TSQL stored procedure GI_ListDictionary, it then parses the returned data and adds it to the gridData list. This method also captures the total number of results returned and stores that value in the totalResults variable.

AddButtonClicked()

This method is called when the Add button is selected. This method takes the word that the user is attempting to add and removes are leading or trailing whitespace. If the word isn’t an empty string, then a call to the TSQL stored procedure GI_AddWordToDictionary is made which will add the word to the dictionary.

Assuming there were no errors, the input textbox is wiped, the grid is refreshed, and a notification informing the user the operation was successful appears. If any errors or checks failed then the error is logged and a notification detailing the problem is displayed to the user.

DeleteButtonClicked(GridCommandEventArgs args)

This method is called when the Delete button is selected on an existing word in the dictionary.

This method first pulls the word value out of the row and calls the TSQL stored procedure GI_RemoveWordFromDictionary which will remove the selected word from the dictionary.

Assuming there were no errors in the operation then the grid is refreshed, and a success notification is displayed to the user. If an error occurred, then it’s logged, and an error notification is displayed to the user.

RefreshButtonOnClickHandler()

This method is called when the Refresh button is selected on the grid. This method simply refreshes the data on the grid.

Updated on February 22, 2023

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support

Leave a Comment