Solved

Adding a Select All button in updateable dashboard 10.2.700

  • 23 November 2022
  • 7 replies
  • 302 views

Userlevel 1

Hello all,

I have written an updateable dashboard to assist with inventory counts, displaying info from PartWhse. There are a couple of UD fields, both checkboxes, that are updateable on the dashboard. All works as per spec, the user can check or uncheck the flags and it saves back to the DB table just fine.

However, I would like to give the user the option of checking or unchecking the checkboxes for all rows to save time, so thinking of adding buttons to the dashboard tracker view. I created a test button and got as far as having the wizard create the private static void, but that’s where my expertise ends! I tried using a foreach statement on ttResults but the Script Editor doesn’t recognise the name.

Has anyone done anything like this before?

Peter

icon

Best answer by cfredrickson 23 November 2022, 17:08

View original

7 replies

Userlevel 3

I’ve done this before by iterating through the table and setting the checkbox values.  That’s worked in the past.  

Userlevel 1

Hi Fred,

That’s kind of where I was heading with my code, but fell at the first hurdle as the Script Editor doesn’t recognise ttResults.

Kind regards,

Peter

Userlevel 3

Sorry, by “table”, I mean you need to get a reference to the grid that’s showing the results and iterate over it’s Rows collection.  

Hi Peter,

 

Here’s a simplified version of the code we use to check a box in all selected rows of a dashboard.

 

private void btnMyButton_Click(object sender, System.EventArgs args)
{
// Get a reference to the data view
EpiDataView edvMyDataView = (EpiDataView)(oTrans.EpiDataViews["MyDataViewID"]); // Swap out 'MyDataViewID' with the actual name of the grid view

// Only continue if at least 1 row is selected
if(edvMyDataView.SelectedRows.Count > 0)
{
// Iterate through all the selected rows
foreach (var row in edvMyDataView.SelectedRows)
{
// Make necessary changes to each row
row.BeginEdit();
row["MyCheckboxColumnName"] = true; // Swap out 'MyCheckboxColumnName' with the actual name of the checkbox column
row["RowMod"] = "U"; // This tells the system this row is being updated
row.EndEdit();
}
}
oTrans.Update();
oTrans.OnSave();
}

 

Userlevel 1

Thanks both of you. Still struggling with this, I tried your code, CF, but got an error “The name 'oTrans' does not exist in the current context”.

Are you customizing the dashboard from within dashboard maintenance?

I think oTrans is not available when customizing the tracker view from dashboard maintenance. You need to deploy the dashboard and add it to the menu. Then you can use oTrans if you add a customization to the tracker view of the menu item. It’s a strange quirk of dashboards that you can have 2 layers of customizations on a tracker view and there are things that work in one but not the other.

 

Does that make sense or do you need more details?

Userlevel 1

Many thanks, that makes perfect sense! Your code worked first attempt after I put it into a customization, brilliant!

Reply