Make a tab invisible - acumatica

I would like to make the activities tab not visible in the screen CR306000.
I used the following code, but the result is KO, while it works on other tabs
Base.Activities.AllowInsert = false;
Base.Activities.AllowUpdate = false;
Base.Activities.AllowDelete = false;
Base.Activities.AllowSelect = false;
<px:PXTabItem RepaintOnDemand="False" Text="Activities" LoadOnDemand="False">

Instead of setting the AllowSelect = false on the DataView itself set it on the DataView's Cache. That should do the trick
Base.Activities.**Cache**.AllowSelect = false;
Alternatively, you can either configure the Visibility Expression or just set the Visible to false from the aspx.

Related

How can I incorporate a PivotTable right into the source data on the sheet (using EPPlus)?

I've been able to create a PivotTable separate from the raw/source data, but now I want to combine the two, with the PivotTable allowing filtering of the spreadsheet data by providing filters on the column heading row, like this:
I tried this code:
private void AddPivotTable()
{
// The commented-out code below placess the PivotTable below the actual data, separate from it:
//string colAlphaRowNum = string.Format("A{0}", locationWorksheet.Dimension.End.Row+5);
// Here I am attempting to incorporate the PivotTable within the data itself (one row above it, actually)
string colAlphaRowNum = "A5";
ExcelAddressBase eab = locationWorksheet.Cells[colAlphaRowNum];
ExcelRangeBase erb = locationWorksheet.Cells[6, 1, locationWorksheet.Dimension.End.Row, locationWorksheet.Dimension.End.Column];
var pt = locationWorksheet.PivotTables.Add(eab, erb, "Pivotous");
pt.RowFields.Add(pt.Fields[0]);
pt.RowFields.Add(pt.Fields[1]);
pt.RowFields.Add(pt.Fields[2]);
pt.RowFields.Add(pt.Fields[3]);
pt.RowFields.Add(pt.Fields[4]);
pt.RowFields.Add(pt.Fields[5]);
pt.MultipleFieldFilters = true;
pt.RowGrandTotals = true;
pt.ColumGrandTotals = true;
pt.Compact = true;
pt.CompactData = true;
pt.GridDropZones = false;
pt.Outline = false;
pt.OutlineData = false;
pt.ShowError = true;
pt.ErrorCaption = "[error]";
pt.ShowHeaders = true;
pt.UseAutoFormatting = true;
pt.ApplyWidthHeightFormats = true;
pt.ShowDrill = true;
pt.DataOnRows = false;
pt.FirstHeaderRow = 1; // first row has headers
pt.FirstDataCol = 1; // first col of data
pt.FirstDataRow = 2; // first row of data
pt.TableStyle = TableStyles.Medium6; // There is a "custom" and several Dark, Light, and Medium options
}
...but this does not work. I get this dialog when I open the generated sheet:
If I select "Yes" this is what I see:
If I select "No", I see this:
...which is promising, but if I then drop down the "Row Labels", deselect the "(Select All)" and then select the first item ("Stern"), I see this:
This is not what I want; in the model (hand-crafted) sheet, deselecting "Select All" and then selecting a single item filters the data to just include that data ("Foster" in this case), like so:
...rather than replacing the first part of the data with a restricted PivotTable.
What do I need to do to make this work as intended?
Perhaps my nomenclature was faulty, because I think what I really want is not necessarily a PivotTable, but the ability to filter.
And, although attempting to do it this way, which seems logical and is even theoretically correct:
using (var shortNameCell = locationWorksheet.Cells[rowToPop, SHORTNAME_BYDCBYLOC_COL])
{
shortNameCell.Value = "Short Name";
shortNameCell.Style.WrapText = false;
shortNameCell.Style.Font.Size = 12;
shortNameCell.AutoFilter = true;
}
using (var companyNameCell = locationWorksheet.Cells[rowToPop, COMPANYNAME_BYDCBYLOC_COL])
{
. . .
companyNameCell.AutoFilter = true;
}
using (var reasonDescCell = locationWorksheet.Cells[rowToPop, REASONDESC_BYDCBYLOC_COL])
{
. . .
reasonDescCell.AutoFilter = true;
}
using (var transTypeCell = locationWorksheet.Cells[rowToPop, TRANSTYPE_BYDCBYLOC_COL])
{
. . .
transTypeCell.AutoFilter = true;
}
...results in only the final column thus appointed to sport filtration abilities, the following works for all four:
locationWorksheet.Cells["A6:D6"].AutoFilter = true;
Using the last, I get the following:
UPDATE
It was a Pivot Table that I needed after all, and what I did to get a start on how to accomplish what I need is shown in my auto-answer here.

Disable/enable an input field

Using this sample code, I am trying to enable/disable the field "arrdatfrom". However, once this text field has been DISABLED, i cannot get it to be re-ENABLED. The function below gets executed when the user clicks a "Refresh" button. I have built this little demo just to prove that I have tried many ways to do this. Any ideas?
function showBooking() {
var d = new Date()
formvals.arrdatefrom = document.getElementById("arrdatfrom").value
formvals.arrdatethru = document.getElementById("arrdatthru").value
formvals.depdatefrom = document.getElementById("depdatfrom").value
formvals.depdatethru = document.getElementById("depdatthru").value
formvals.bookname = document.getElementById("bookname").value
formvals.peakroomfrom = document.getElementById("peakroomfrom").value
formvals.peakroomthru = document.getElementById("peakroomthru").value
formvals.peakattendfrom = document.getElementById("peakattendfrom").value
formvals.peakattendthru = document.getElementById("peakattendthru").value
alert (' ngs.hta ready to enable')
document.getElementById("arrdatfrom").enabled = 'true'
alert ('ngs.hta in showBooking!! disable. ')
document.getElementById("arrdatfrom").disabled = 'true'
...
There is no property .enabled. To re-enable a disabled element, set .disabled = false.

How to set Spinner selection by value, using CursorAdapter

I have a spinner I'm populating from the database. I want to choose which item from the list is selected by default. I need to find out what item in the list (CursorAdapter) has the value "Default Away" and set that to the selected value.
Spinner away_team_spinner = (Spinner)findViewById(R.id.away_team_spinner);
DatabaseHelper db = new DatabaseHelper(this);
Cursor team_list = db.getTeams(p_game_level);
startManagingCursor(team_list);
String[] team_name = new String[]{colTeamName};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, team_list, team_name, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
away_team_spinner.setAdapter(adapter);
//// HERE IS WHERE MY ERRORS START ////
Log.i("NEW_GAME","Before set arrayadapter");
CursorAdapter adapter_choose = (CursorAdapter)away_team_spinner.getAdapter();
Log.i("NEW_GAME","Before set setSelection");
away_team_spinner.setSelection(adapter_choose.getPosition("Default Away"));
This is the "solution" I found by searching on this web site. However, I cannot use "getPosition" with CursorAdapter object. I tried ArrayAdapter, but then the line after "Before set arrayadapter" comment errors with "android.widget.SimpleCursorAdapter cannot be cast to android.widget.ArrayAdapter". What am I doing wrong? Thanks.
have you thought about running a for loop until you find the position then set the adapter position that way? ill draft up some code then test it, i'm doing something similar
and well this just did the trick, enjoy!
int cpos = 0;
for(int i = 0; i < simpleCursorAdapter.getCount(); i++){
cursor.moveToPosition(i);
String temp = cursor.getString((your column index, an int));
if ( temp.contentEquals(yourString)){
Log.d("TAG", "Found match");
cpos = i;
break;
}
}
spinner.setSelection(cpos);

Setting DisplayMemberPath of ComboBox in code

In my WPF program I have:
string queryString = "Select AccountID, ProjectName from Foo where IsEnabled = 1";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, sConn1);
DataSet dsAccounts = new DataSet();
adapter.Fill(dsAccounts, "Accounts");
cbAccount.ItemsSource = dsAccounts.Tables["Accounts"].AsEnumerable();
cbAccount.DisplayMemberPath = "ProjectName";
When my program runs and I dropdown the ComboBox all the rows are there but they display as blanks. When I click on a row, my SelectionChanged event handler properly identifies the selected row and picks up the proper values.
I believe my problem is with the DisplayMemberPath.
What am I doing wrong?
This is not an answer but rather a workaround. This works:
cbAccount.DataContext = dsAccounts.Tables["Accounts"];
//cbAccount.ItemsSource = dsAccounts.Tables["Accounts"].AsEnumerable();
cbAccount.DisplayMemberPath = "ProjectName";
By setting the DataContext reather than the ItemSource then the DisplayMemberPath is being set properly.
The question remains open, there must be a way to properly set the DisplayMemberPath when one has an ItemSource rather than a DataContext.
I believe the problem is that your table accounts is not serialized to objects.
If you use a list of accounts instead of your tables then it works perfect with the ItemsSource and DisplayMemeberPath.

Why does calling the YUI Datatable showCellEditor not display the editor?

Clicking on the second cell (any row) in the datatable causes the cell editor to display. But, I am trying to display the cell editor from code. The code looks like the following:
var firstEl = oDataTable.getFirstTdEl(rowIndex);
var secondCell = oDataTable.getNextTdEl(firstEl);
oDataTable.showCellEditor(secondCell);
When I debug into the datatable.js code (either with a click or from the code above) it follows the same path through the showCellEditor function but the above code will not display the editor.
I am using YUI version 2.8.0r4.
I think this is blur events issue.
So, for example, I have link that must add record to datatable, and show its editor.
var mymethod = function (e) {
YAHOO.util.Event.stopEvent(e);
var r = {};
r.id = 0;
r.value = 'hello world';
myDataTable.addRow(r);
var cell = myDataTable.getLastTrEl().cells[0];
myDataTable.showCellEditor(cell);
}
YAHOO.util.Event.addListener('mylink2addrecord_ID', 'click', mymethod);
Without stopEvent you will never see editor, because there is tableBlur event called when you click on yourlink....
You can try this - this is ONLY a snippet from a larger piece of an event handler set of code I have. EditNext is the function that moves over a cell and displays the editor, if the cell has one:
this.myDataTable.subscribe("editorKeydownEvent",function(oArgs) {
var self = this,
ed = this._oCellEditor, // Should be: oArgs.editor, see: http://yuilibrary.com/projects/yui2/ticket/2513909
ev = oArgs.event,
KEY = YAHOO.util.KeyListener.KEY,
Textbox = YAHOO.widget.TextboxCellEditor,
Textarea = YAHOO.widget.TextareaCellEditor,
DCE = YAHOO.widget.DateCellEditor,
cell = ed.getTdEl(),
col = ed.getColumn(),
row,rec,
editNext = function(cell) {
cell = self.getNextTdEl(cell);
while (cell && !self.getColumn(cell).editor) {
cell = self.getNextTdEl(cell);
}
if (cell) {
self.showCellEditor(cell);
}
},
As mac said, you need to stop the previous event. For some reason it (the tableBlur event) conflicts with the showCellEditor function. This is the first place which had a resolution to the problem.
To sum it up, all I did was:
YAHOO.util.Event.stopEvent(window.event);<br/>
dt.showCellEditor(td); // dt = yui datatable obj, td = {record: yuirecord, column: yuicolumn}
Of course if you have the event object readily available as mac's post does, you can pass it to stopEvent(e) like he did.

Resources