Create own menu_button in ALV toolbar - toolbar

I have to create a menu_button in my ALV toolbar,
I searched in SCN and I found some examples.
I know that we have to create a button with the btn_type = 2
like that :
CLEAR: ls_buttn.
ls_buttn-icon = gi_livra.
ls_buttn-butn_type = 2.
ls_buttn-text = 'Vue Livraison'.
ls_buttn-quickinfo = 'Vue Livraison'.
ls_buttn-function = 'LIVRAISON'.
APPEND ls_buttn TO e_object->mt_toolbar.
After that I have to handle menu button im my class
like that:
METHODS handle_menubtn FOR EVENT menu_button OF cl_gui_alv_grid
IMPORTING e_object e_ucomm,
After that to implement it
METHOD handle_menubtn.
IF e_ucomm = 'LIVRAISON'.
CALL METHOD e_object->add_function
EXPORTING
fcode = 'DISPLAY'
text = 'DISPLAY'.
ENDIF.
ENDMETHOD.
But it does not work. The debugger does not go into this method when I click on my button.
Why?

I think that what you did is right but maybe you forgot to
SET HANDLER lr_event->handle_menubtn FOR your_alv.
Regards,

Related

Button with Icon and Label

Hello I'm currently looking for a way to display a button with icon and label.
I want the icon to be on the left side and the label left-aligned on the right side of the Icon.
I don't think this is possible in openedge but maybe one has an idea for this.
I'm using an abl-frame and the button needs to be generated dynamically
I have a very ugly solution for you:
Create an image containing the entire face of the button. Icon and text included. Perhaps not a beautiful solution but you won't need to use .Net.
Basically it will just add the IMAGE-UP attribute for the button.
DEFINE BUTTON BUTTON-3
IMAGE-UP FILE "c:/temp/button.png":U
LABEL "Button 3"
SIZE 48 BY 4.29.
button.png:
Add that image to your button.
Result:
If you need to set different pictures based on contrast you will need to check Registry for contrast setting. That can be done something like this:
DEFINE VARIABLE cContrast AS CHARACTER NO-UNDO.
LOAD "Control Panel" BASE-KEY "HKEY_CURRENT_USER".
USE "Control Panel".
GET-KEY-VALUE SECTION "Accessibility\HighContrast" KEY "Flags" VALUE cContrast.
UNLOAD "Control Panel".
IF cContrast = "126" THEN
MESSAGE "Low contrast" VIEW-AS ALERT-BOX.
ELSE IF cContrast = "127" THEN
MESSAGE "High contrast" VIEW-AS ALERT-BOX.
If you are not on a completely obsolete version of Progress OpenEdge then you can use .Net controls, the visual designer in Progress Developer Studio for OpenEdge (PDSOE) will let you drag and drop the following together:
This generates the following source code (which you can also use to generate form creation):
USING Progress.Lang.*.
USING Progress.Windows.Form.
BLOCK-LEVEL ON ERROR UNDO, THROW.
CLASS button INHERITS Form:
DEFINE PRIVATE VARIABLE button1 AS System.Windows.Forms.Button NO-UNDO.
DEFINE PRIVATE VARIABLE components AS System.ComponentModel.IContainer NO-UNDO.
CONSTRUCTOR PUBLIC button ( ):
SUPER().
InitializeComponent().
THIS-OBJECT:ComponentsCollection:ADD(THIS-OBJECT:components).
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END CONSTRUCTOR.
METHOD PRIVATE VOID InitializeComponent( ):
/* NOTE: The following method is automatically generated.
We strongly suggest that the contents of this method only be modified using the
Visual Designer to avoid any incompatible modifications.
Modifying the contents of this method using a code editor will invalidate any support for this file. */
#VisualDesigner.FormMember (NeedsInitialize="true").
DEFINE VARIABLE resources AS Progress.Util.ResourceManager NO-UNDO.
resources = NEW Progress.Util.ResourceManager("button").
THIS-OBJECT:button1 = NEW System.Windows.Forms.Button().
THIS-OBJECT:SuspendLayout().
/* */
/* button1 */
/* */
THIS-OBJECT:button1:Image = CAST(resources:GetObject("button1.Image"), System.Drawing.Image).
THIS-OBJECT:button1:ImageAlign = System.Drawing.ContentAlignment:MiddleLeft.
THIS-OBJECT:button1:Location = NEW System.Drawing.Point(13, 212).
THIS-OBJECT:button1:Name = "button1".
THIS-OBJECT:button1:Size = NEW System.Drawing.Size(108, 42).
THIS-OBJECT:button1:TabIndex = 0.
THIS-OBJECT:button1:Text = "Exit".
THIS-OBJECT:button1:TextAlign = System.Drawing.ContentAlignment:MiddleRight.
THIS-OBJECT:button1:UseCompatibleTextRendering = TRUE.
THIS-OBJECT:button1:UseVisualStyleBackColor = TRUE.
/* */
/* button */
/* */
THIS-OBJECT:ClientSize = NEW System.Drawing.Size(292, 266).
THIS-OBJECT:Controls:Add(THIS-OBJECT:button1).
THIS-OBJECT:Name = "button".
THIS-OBJECT:Text = "button".
THIS-OBJECT:ResumeLayout(FALSE).
CATCH e AS Progress.Lang.Error:
UNDO, THROW e.
END CATCH.
END METHOD.
DESTRUCTOR PUBLIC button ( ):
END DESTRUCTOR.
END CLASS.
The drag and drop method will also by default create a resx file which is an xml file containing the resources used, the image is encoded in there:
<data mimetype="application/x-microsoft.net.object.bytearray.base64" name="button1.Image" type="System.Drawing.Bitmap, System.Drawing">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wgAADsIBFShKgAAAAJFJREFUOE/N0EEOgCAMRFEP4tL738wz1CaDQYa2FmThX5FIH8gmi/otdO4HFtNV
aNSikfproxZtbt4ob/Xb+LEzkHmeAcWW95Uh5O0OjslCIDxFsyHtORMTyIU0DGcULYK0pKK93AjK/I3o
Ip+gsrojuo+hYCC2Gig+E3lchTIKMq0Ceed49fvtx860DKIWQSIXxapUG1GIZgoAAAAASUVORK5CYII=
</value>
When generating your forms with code you do not need the resx files and can load images etc from the file system.

ALV Grid toolbar is missing in fullscreen

I've created a simple ALV grid and populated the grid with data, now the grid is displayed after the selection screen. I'm not using custom container and display the grid in full screen.
Is there a property of ALV grid object that enables toolbar with buttons filter, sort, etc, that is normally on top of the grid?
So far this is what I have:
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = tbl_data
).
CATCH cx_salv_msg.
ENDTRY.
* initialize the alv settings - nothing done here for the moment.
PERFORM define_settings USING gr_alv.
* Display the ALV
gr_alv->display( ).
Each ALV function is implemented as a separate CLASS in Simple ALV, so you have to handle them separately. You do not need a custom control.
In order to add the toolbar:
data: lr_func TYPE REF TO CL_SALV_FUNCTIONS_LIST.
"Functions
lr_func = gr_alv->get_functions( ).
lr_func->set_all( ).
Complete ALV display:
form display_results.
data: ls_key type salv_s_layout_key,
lo_table type ref to cl_salv_table,
lo_cols type ref to cl_salv_columns_table,
lo_events type ref to cl_salv_events_table,
lo_funcs type ref to cl_salv_functions_list,
lo_layout type ref to cl_salv_layout,
lo_display type ref to cl_salv_display_settings,
lo_selections type ref to cl_salv_selections.
try.
call method cl_salv_table=>factory
exporting
list_display = abap_false
importing
r_salv_table = lo_table
changing
t_table = gt_list.
catch cx_salv_msg . "#EC NO_HANDLER
endtry.
"Events
create object go_events.
lo_events = lo_table->get_event( ).
set handler go_events->double_click for lo_events.
"Layouts
ls_key-report = sy-repid.
lo_layout = lo_table->get_layout( ).
lo_layout->set_key( ls_key ).
lo_layout->set_default( abap_true ).
lo_layout->set_save_restriction( ).
lo_layout->set_initial_layout( p_var ).
lo_cols = lo_table->get_columns( ).
perform change_columns changing lo_cols.
"Functions
lo_funcs = lo_table->get_functions( ).
lo_funcs->set_all( ).
"Display Settings
lo_display = lo_table->get_display_settings( ).
lo_display->set_striped_pattern( abap_true ).
"Selections
lo_selections = lo_table->get_selections( ).
lo_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
lo_table->display( ).
endform. " DISPLAY_RESULTS
This is confusing at first when you use the ALV object model. If you use the ALV in fullscreen mode you have to reference a GUI status in your program, and use the method SET_SCREEN_STATUS on your grid instance. It's explained in the SAP Help here.
It helps to copy the GUI status SALV_TABLE_STANDARD from function group SALV_METADATA_STATUS into your report as a starting point, and then you can remove any functions you don't need. For example, if you copied the status into your program as ALV_STATUS, you would write:
gr_alv->set_screen_status( report = sy-repid
pfstatus = 'ALV_STATUS' ).
If you want to use the class-based model of setting up ALV functions, you have to embed the grid object in a custom container in a screen.
Seems what you need to do is get an instance of CL_SALV_FUNCTIONS_LIST from your grid object like so:
data: lr_func TYPE REF TO CL_SALV_FUNCTIONS_LIST.
lr_func = gr_alv->get_functions( ).
lr_func->set_all( ).
But, from there, it seems you need to do a bit or work. My advice: Look at the documentation on classes CL_SALV_TABLE and CL_SALV_FUNCTIONS_LIST (that is, click the documentation button when you display the class in transaction SE24). The latter tells you exactly what you need to do.
(Also, a little hint: Put your processing logic inside the try-catch block, because if the initialization fails, you might catch that exception but go on to try call a method on an uninstantiated or uninitialized class).
add a customer container to your gui
create an object of the class cl_gui_custom_container and supply the name of your container
create an instance of the class cl_gui_alv_grid and supply the custom container object
use the method set_table_for_first_display
this will display a toolbar with all buttons. you can control which buttons you want in the toolbar with the IT_TOOLBAR_EXCLUDING parameter to the set_table_for_first_display method.

ASP.NET Dynamical Creating Custom Control

I created user control and want to add it to page. I use next code:
Controls_MultiTextInput cc = new Controls_MultiTextInput();
Controls.Add(cc);
But control doesn't appear on page. What is wrong?
this.Controls.Add(this.LoadControl("MultiTextInput.ascx")) is the correct way to load the control because it needs to know where the ascx file is.
If you want to set properties, do this:
Controls_MultiTextInput cc = (Controls_MultiTextInput) LoadControl("MultiTextInput.ascx");
cc.MyProperty = "abc";
Controls.Add(cc);
Anton you can set properties !
Controls_MultiTextInput cc
= (Controls_MultiTextInpu)Page.LoadControl("MultiTextInput.ascx");
cc.variable = 2;
cc.SetProperties(223,2311);
Controls.Add(cc);
or
PlaceHolder.Controls.Add(cc);

How to display popup from code-behind in ASP.net?

I wonder how it would be possible to launch a series of popups, containing a form,
from code-behind.
I possess a list of objects 'Products'
and I wish I could change one property (quantity) of each "product".
Here's how I build my list (normally I use a database).
Private List<Product> listProduct;
listProduits = new List<Product>();
Product objProduit_1 = new Produit;
objProduct_1.ref = "001";
objProduct_1.article = "G900";
objProduct_1.quantity = 30;
listProducts.Add(objProduct_1);
ProductobjProduit_2 = new Product;
objProduct_2.ref = "002";
objProduct_2.article = "G900";
objProduct_2.quantity = 35;
listProduits.Add(objProduct_2);
And I would like displayed popup one after one.
Thank you in advance for your help
you'll need to write some client side code that produces what you're looking for. The AJAX Control tool kit may be along the lines of what you're looking for.

listening for viewstack change event

I have a piece of software I'm working on that is using a viewstack with 3 canvases. With the change event I need to look for index 2 which is the last canvas when it changes to this canvas I need it to grab data from inputs from the previous two canvases.
Within the viewstack events I've assigned the function change() to the event childIndexChange.
Here is the method:
private function change():void
{
Alert.show(customerViewStack.selectedIndex.toString());
}
eventually this method will look something like this:
public function change():void
{
if(customerViewStack.selectedIndex == 2)
{
rCID.text = cidTxt.text;
rCNAME.text = nameTxt.text;
rCACCTN.text = acctNumTxt.text;
rCACCTR.text = acctRep.text;
rCWEB.text = website.text;
rCACTIVE.text = active.text;
rCSTREET.text = cStreet.text + " "+ cSuite.text;
rCCSZ.text = cCity.text + ", " + cState.text + " " + cZipcode.text;
rCPHN.text = cPhone.text;
rCAPHN.text = cPhone0.text;
rCFAX.text = cFax.text;
}
}
to alternate through my views im using this approach with buttons actually inside the canvases:
customerViewStack.selectedChild=cAddress
anyway the problem is the event doesn't seem to be firing my change function because no alert is coming up also the way I'm doing this is probably quite naive so if you have any suggestions please I'm open.
I've taken another approach I'm going to bypass "deferred instantiation" and turn the cereationPolicy to all. The view before the last I will set values from there then transition over.
However if anyone has any thoughts or criticism please feel free.
The change event will fire when the view is changed, so simply subscribing to this event instead of childIndexChange should solve the problem.

Resources