Reset show/hide columns to pre-defined default

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
nbush78
New User
Posts: 3
Joined: Tue Nov 19, 2019 9:58 am
First Name: Nathan
Last Name: Bush
Company Name: Gartman LLC
Address 1: 1100 S Rock St.
City: Sheridan
State / Province: Arkansas
Zip / Postal Code: 72150
Country: United States
Contact:

Reset show/hide columns to pre-defined default

Post by nbush78 »

We're currently using the onload event of the record format to set default show/hide columns if no local storage key/value exist for a grid. This works well. The issue is when the reset option is taken on the grid. I would like to use the onfilterchange event of the grid to re-execute the onload event of the record format to re-apply the defaults. Currently I have copied the same code from onload and have it in the onfilterchange as well. But now have two places to update if we want to change the default show/hide columns.
Last edited by nbush78 on Thu Jan 30, 2020 3:34 pm, edited 1 time in total.
nbush78
New User
Posts: 3
Joined: Tue Nov 19, 2019 9:58 am
First Name: Nathan
Last Name: Bush
Company Name: Gartman LLC
Address 1: 1100 S Rock St.
City: Sheridan
State / Province: Arkansas
Zip / Postal Code: 72150
Country: United States
Contact:

Re: Re-execute onload event

Post by nbush78 »

So onfilterchange isn't the best solution. Is there any event that triggers after reset?
Last edited by nbush78 on Mon Jan 13, 2020 1:11 pm, edited 1 time in total.
nbush78
New User
Posts: 3
Joined: Tue Nov 19, 2019 9:58 am
First Name: Nathan
Last Name: Bush
Company Name: Gartman LLC
Address 1: 1100 S Rock St.
City: Sheridan
State / Province: Arkansas
Zip / Postal Code: 72150
Country: United States
Contact:

Re: Re-execute onload event

Post by nbush78 »

Solution so far:
Using External JS (Screen Level)
Record Format onLoad event references the external js.
Grid onFilterChange references the external js and passes a value to designate that it is executing from onFilterChange

External JS checks to see if the local storage for the persistant state is null or if execution from onFilterChange
If so, set grid defaults (currently just show/hide columns)

Issue is onFilterChange was not meant for this. If not a separate event then just a variable that I could pass to the ExternalJS from the onFilterChange event to designate that the onFilterChange was executed because of reset vs a true filter change. Vurrently I check for this in the OnFilterChange Event via:

Code: Select all

try {
  var reset = arguments.callee.caller.caller.caller.arguments[0].target.innerText;
}
catch(err) {
  reset = '';
}
if (reset == 'Reset') {
  uniqueGridID_DefaultView(reset);
}
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Re-execute onload event

Post by Scott Klement »

I don't think anyone has tried to do this before? Or, at least, I haven't run across it.

I do have an idea, though... you could call the grid's getFilter() method for each column (in a loop.) This function returns null if no filter was set, so you could use this to determine if nothing has been filtered. This would allow you to pass a flag to your function so that it could tell that there aren't any filters.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest