As someone new to TypeScript and MVC, I find myself unsure if I am even asking the right questions. I have multiple TypeScript files with identical functionality that are used across various search screens. My goal is to consolidate these into a single file by passing the search screen name and area (both strings) to it. Is there a way to achieve this by sending this information from the view to the TypeScript file?
To provide some context, here is a snippet of my TypeScript code:
module HarSearch {
const area = "";
const searchScreen = "";
const gridName = searchScreen + "SearchGrid";
const searchGrid = $(`#${gridName}`);
const gridOptionsStorageName = searchScreen + "GridOptions";
const filtersStorageName = searchScreen + "SearchFilters";
const filterFormName = "formFilters";
var defaultGridOptions: kendo.ui.GridOptions;
$(function(e) {
var harSearchGridData = searchGrid.data("kendoGrid");
KendoGridFunctions.resizeGrid(searchGrid, -25);
defaultGridOptions = harSearchGridData.getOptions();
loadSearchState();
});
// additional functions...
}
I am specifically looking for ways to set the values for 'area' and 'searchName' dynamically.
EDIT: Taking Paleo's advice into consideration, I have made some changes to my code by moving the necessary variables into their own class. However, I still need a mechanism to assign values to these variables.
class definitions {
public static area = "";
public static searchName = "";
}
module HarSearch {
const area = definitions.area;
const searchName = definitions.searchName;
.
.
.
// remaining code remains unchanged
}