Under ax 2009 my requirement is to open a dialog box when I opens a report and it should show a drop down. So currently my drop down is SiteId from InventSite table. As show in code below.
public class ReportRun extends ObjectRun
{
//Dialog
DialogField dfSiteName;
//Range
InventSiteId siteName;
}
public boolean getFromDialog()
{
;
siteName = dfSiteName.value();
return true;
}
public Object dialog(Object _dialog)
{
DialogRunBase dialog;
FormDateControl siteNameControl;
;
dialog = super(_dialog);
dialog.caption("Sales Overview Range Dialog");
dialog.addGroup("Selec Range");
dfSiteName = dialog.addField(typeid(InventSiteId),"Site","Select Range");
siteNameControl = dfSiteName.control();
siteNameControl.mandatory(true);
return dialog;
}
Everything is working fine with this code. Now instead drop down of SiteId from InventSite table in dialog box I want drop down of Dimension[1] from InventSite table in dialog box. I am not able to do that. Please guide me on this.
If you code work fine and you want to add only the Dimension[1] from inventSite table go to AOT\Data Dictionary\Tables\InventSite\Field Groups\AutoLookup here you there you will see SiteId and Name fields. You need to add new field then go to properties of this new field and select in property DataField the field that you need.
If you add this new field will be visible in all lookups for InventSiteId edt.
Related
I am selecting multiple lines (ctrl/shift+click) from the grid on the Sales Order screen and want an action to have access to what was selected. How do I access the list of what's selected on the grid from the code behind?
As stated, add the selected screen. First you would add a DAC extension to add the selected field, which is not a DB field.
#region Selected
[PXBool]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected { get; set; }
public abstract class selected : PX.Data.BQL.BqlBool.Field<selected> { }
#endregion
From there, you can add the selected field to your table in the UI. Also, ensure that commit changes is set on that field, or an action that you may call to query.
Finally, you can just run a foreach for the view, and check for the selected field you added:
foreach (SOLine line in Base.Transactions.Select())
{
SOLineExt lineExt = line.GetExtension<SOLineExt>();
if (line.Selected == true)
{
//execute code on the record
}
}
I am trying to add a value to an editable combo box called nameComboBox that I created in the Scene Builder.
I populate the combo box with this code:
private ObservableList<String> getNames()
{
return (FXCollections.observableArrayList("Freddy","Kerstin"));
}
..
nameComboBox.getSelectionModel().select(getNames());
I have a Save button defined form the Scene Builder. The code looks like this:
#FXML
private void handleSaveBtn()
{
System.out.println("The new name is " + nameComboBox.getValue());
}
When the scene is displayed, the combo boxes editable field is displayed empty with the two names hidden in the list underneath the empty field, which is what I want to happen.
If then type "Rusty" in the empty field and click a save button all that happens is that the println statement returns
"The new name is null".
If I wanted to do something with the new value, like validate it or store it in a database, how do I get the value that I entered in the editable field?
Try using this instead of .getValue() :
nameComboBox.getEditor().getText()
This returns the value of the textProperty of the TextField (.getEditor()) of the editable ComboBox.
try this
nameComboBox.setItems(getNames());
nameComboBox.setValue("Freddy");
I have created a menu item, which i added onto an ActionPane. The Menu Item runs an Output menu item which runs a Report. What I want to accomplish is, when a user clicks the menu item I want AX2012 to directly print the report.
display str ItemID(ItemId itemId)
{
str returnValue;
InventTable inventTable;
;
returnValue = this.ItemId;
return returnValue;
}
I am returning the ItemId on the report. How I can trigger AX2012 to directly print the report (with the ItemId) when the menu button is clicked?
I am getting NullPointerException in the code for contextmenu.
here is the onCreateContextmenu Method
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, MENU_EDIT, 0, "Edit");
menu.add(0, MENU_DELETE, 0, "Delete");
}
I am getting the error in the line long buttonId = info.id; in the code below
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
long buttonId = info.id;
switch (item.getItemId()) {
case MENU_EDIT:
function1(buttonId);
break;
case MENU_DELETE:
function2(buttonId);
break;
}
return true;
}
Can some one help me fix this
view isn't passed to onContextItemSelected and
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
long buttonId = info.id;
This code doesn't help because menuInfo is null when view is a button. The Android doc says "menuInfo Extra information about the item for which the context menu should be shown. This information will vary depending on the class ofv". When v is a ListView menuInfoapproach is fine. When it is a Button, it doesn't work.
In onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo), the View v is the button that produced the context menu. Copyv to a global View varaiable and use that where you need to have the view of the button that produced the context menu.
How to get the Button view which triggered a Context Menu?
This problem has bugged me for several years and maybe someone here knows a simple solution, since I just ran into it again.
QUESTION: Is there any way to get the XtraGrid to "forget" the current focused row index before a new (different) datasource is assigned to the grid?
BACKGROUND
We use the XtraGrid as a kind of controller for what is displayed in another panel of a multipane Winform.
Now imagine a hypothetical scenario where the datasource of the XtraGrid keeps changing according to menu selections. Menu item 1 populates the grid with a list of today's entrees in the cafeteria: Id, Name. Menu item 2 populates the grid with a list of Customers the user must phone that day: ID, Name. Important thing is that these are separate distinct datasources, and the grid's datasource is being assigned and reassigned.
CRITICAL FACT FOR THIS QUESTION:
We want the grid's FocusedRowChanged event to be the single place where we trap the user's selection in the controller grid. We are a "no spaghetti code" shop. FocusedRowChanged is better than a click event because it handles keyboard navigation too. The row with the focus contains the ID of the detail record we need to fetch from the database for display in Panel #2. This works--most of the time.
Here's how it doesn't work: let's say that on a given day, the list of customers the user must contact contains only one row. So the first (and only) row in the grid is the focused row. Now let's say that the user goes up to the menu and selects the menu item to display the day's cafeteria entrees. When the user clicks on the first item in the Entrees list, the FocusedRowChanged event does NOT fire because the grid has retained a memory of the focused row index from the previous datasource. The focused row index has not changed. And thus the user's selection doesn't trigger anything.
I tried to get DevExpress to offer a second more row-object-oriented mode (as distinct from row-index-oriented approach) whereby each row in the grid would have a GUID, and the FocusedRowChanged event would fire whenever the GUID of the currently focused row differed from the GUID of the previously focused row, regardless of whether the focused row index happened to be the same. This would allow dynamic changes of datasource and enable the desired behavior. But they demurred.
So I'll ask my question again, Is there any way to get the XtraGrid to "forget" the current focused row index before a new datasource is assigned to the grid?
Tim, I had the exact same problem when the grid only had one row of data in it and then changed data sources. I solved it by setting the gridview.FocusedRowHandle = -1 after setting the new datasource.
In a similar situation, I am subscribing to the
FocusedRowObjectChanged
event (using DevExpress 16.1).
I think that the best solution to this problem is to create a new GridView object and override its DoChangeFocusedRowInternal method. Below you will find the default implementation of this method. All you need to do is to change the marked row just as your needs dictate. Also, take a look at the How to create a GridView descendant class and register it for design-time use article, it contains some useful information.
public class MyGridView : GridView {
protected override void DoChangeFocusedRowInternal(int newRowHandle, bool updateCurrentRow) {
if(this.lockFocusedRowChange != 0) return;
if(!IsValidRowHandle(newRowHandle))
newRowHandle = DevExpress.Data.DataController.InvalidRow;
if(FocusedRowHandle == newRowHandle) return; // <<<<<<
int currentRowHandle = FocusedRowHandle;
BeginLockFocusedRowChange();
try {
DoChangeFocusedRow(FocusedRowHandle, newRowHandle, updateCurrentRow);
}
finally {
EndLockFocusedRowChange();
}
RaiseFocusedRowChanged(currentRowHandle, newRowHandle);
}
}
UPDATE
My code:
namespace MyXtraGrid {
public class MyGridControl : GridControl {
protected override BaseView CreateDefaultView() {
return CreateView("MyGridView");
}
protected override void RegisterAvailableViewsCore(InfoCollection collection) {
base.RegisterAvailableViewsCore(collection);
collection.Add(new MyGridViewInfoRegistrator());
}
}
public class MyGridViewInfoRegistrator : GridInfoRegistrator {
public override string ViewName { get { return "MyGridView"; } }
public override BaseView CreateView(GridControl grid) {
return new MyGridView(grid as GridControl);
}
}
public class MyGridView : GridView {
public MyGridView(GridControl ownerGrid) : base(ownerGrid) { }
public MyGridView() { }
protected virtual bool RowEqual(int focusedRowHandle, int newRowHandle) {
if(IsDesignMode)
return focusedRowHandle == newRowHandle;
DataRow row1 = GetDataRow(focusedRowHandle);
DataRow row2 = GetDataRow(newRowHandle);
return row1 == row2;
}
protected override void DoChangeFocusedRowInternal(int newRowHandle, bool updateCurrentRow) {
if(this.lockFocusedRowChange != 0) return;
if(!IsValidRowHandle(newRowHandle))
newRowHandle = DevExpress.Data.DataController.InvalidRow;
if(RowEqual(FocusedRowHandle, newRowHandle))
return;
int currentRowHandle = FocusedRowHandle;
BeginLockFocusedRowChange();
try {
DoChangeFocusedRow(FocusedRowHandle, newRowHandle, updateCurrentRow);
}
finally {
EndLockFocusedRowChange();
}
RaiseFocusedRowChanged(currentRowHandle, newRowHandle);
}
}
}
You can subscribe on the DataSourceChanged event which will fire when Data source changes (you guessed it!) so then you can get using GetFocusedObject() the object and display the relevant items for the other grid...