Data grid Click event
I have 4 columns in my datagrid,and 4 list box and test input
field when i select some value in list box and then press a button
it is added to Datagrid 1st row in 3 columns , and when i click
another button to add a value in 4th column of 1st row it should
display, but it displays in 4th column of 2nd row . kindly let me
know the process how to display two click events in a single row of
datagrid
thanks in advance
Clicking Two buttons should display two different values in
Datagrid in a single row
The second click has no way of knowing the data from the
first click exists. You could just add the second click data to the
dataprovider last item, but then you need to think about how to
structure and access the data. XML in XMLListCollection is probably
best.
Similar Messages
-
Haw can i handle the single-click mouse event in a ALV Grid class implementation...???
The LEFT_CLICK_RUN and RIGHT_CLICK don't help's me....
Someone can update me...???
Thank's...hi,
you can just set all the field as hotspot , and implement the event hotspot_click.
check the code below:
pay attention the words in red
REPORT ZDAVID_ALV1.
CLASS ZCL_EVENT_RECEIVER DEFINITION DEFERRED." Declear a custom class
tables zemployee.
data: ls_fcat type lvc_s_fcat,
li_fcat type lvc_t_fcat,
ls_layo type lvc_s_layo,
ls_color type lvc_s_scol,
LO_EVENT TYPE REF TO ZCL_EVENT_RECEIVER.
data: container type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
types: begin of ty_emp,
emp_x type c,
zemp_id type zemp_id,
zemp_name type zemp_name,
zemp_salary type zemp_salary,
zemp_dpart type zemp_dpart,
rowcolor(4) type c,
cellcolor type lvc_t_scol,
end of ty_emp.
data: emp type table of ty_emp,
wa_emp type ty_emp,
wcellcolor type lvc_s_scol.
call screen 9000.
CLASS ZCL_EVENT_RECEIVER DEFINITION." class definition
PUBLIC SECTION.
methods:
handle_single_click
for event hotspot_click of cl_gui_alv_grid
importing
e_row_id es_row_no e_column_id.
PRIVATE SECTION.
ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION
* LCL_EVENT_RECEIVER (DEFINITION)
* ===============================================================
* LOCAL CLASSES: IMPLEMENTATION
* ===============================================================
* CLASS LCL_EVENT_RECEIVER (IMPLEMENTATION)
* IN THIS EXAMPLE, ONLY EVENT DOUBLE_CLICK IS CAUGHT
CLASS ZCL_EVENT_RECEIVER IMPLEMENTATION." implementation
method handle_single_click.
message e_column_id-fieldname type 'I'.
endmethod.
ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION
form sub_get_data.
select * from zemployee into corresponding fields of wa_emp.
wa_emp-emp_x = 'X'.
if wa_emp-zemp_id = '171184'.
" wa_emp-rowcolor = 'C610'.
wcellcolor-fname = 'ZEMP_ID'.
wcellcolor-color-col = '7'.
wcellcolor-color-int = '1'.
append wcellcolor to wa_emp-cellcolor.
ENDIF.
append wa_emp to emp.
CLEAR WA_EMP. clear wcellcolor.
endselect.
endform.
form sub_create_obj.
if container is initial.
create object container
exporting
container_name = 'MYCONT'.
endif.
if grid is initial.
create object grid
exporting
i_parent = container.
endif.
endform.
form sub_call_alv.
call method grid->set_table_for_first_display
exporting
is_layout = ls_layo
changing
it_outtab = emp
it_fieldcatalog = li_fcat
"it_sort = i_sort2
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
if sy-subrc <> 0.
endif.
create object lo_event.
set handler lo_event->handle_single_click for grid." set handler
endform.
form sub_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'EMP_X'.
ls_fcat-coltext = 'Check'.
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
ls_fcat-hotspot = 'X'." hotspot
append ls_fcat to li_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ZEMP_ID'.
ls_fcat-coltext = 'ID'.
append ls_fcat to li_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ZEMP_NAME'.
ls_fcat-coltext = 'Name'.
append ls_fcat to li_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ZEMP_SALARY'.
ls_fcat-coltext = 'Salary'.
ls_fcat-do_sum = 'X'.
append ls_fcat to li_fcat.
clear ls_fcat.
ls_fcat-fieldname = 'ZEMP_DPART'.
ls_fcat-coltext = 'Department'.
ls_fcat-drdn_hndl = '1'.
ls_fcat-edit = 'X'.
append ls_fcat to li_fcat.
clear ls_fcat.
endform.
form sub_layout.
ls_layo-zebra = 'X'.
ls_layo-INFO_FNAME = 'ROWCOLOR'.
endform.
module pbo output.
perform sub_get_data.
perform sub_fcat.
perform sub_layout.
perform sub_create_obj.
perform sub_drop.
perform sub_call_alv.
endmodule.
module pai input.
data: ok_code type sy-ucomm.
case ok_code.
when 'SHOW'.
MESSAGE 'D' TYPE 'I'.
WHEN 'EXIT'.
leave program.
WHEN OTHERS.
ENDCASE.
clear ok_code.
endmodule.
form sub_drop.
data: wa_drop type lvc_s_drop,
drop type lvc_t_drop.
wa_drop-handle = '1'.
wa_drop-value = 'Dev'.
append wa_drop to drop.
clear wa_drop.
wa_drop-handle = '1'.
wa_drop-value = 'Testing'.
append wa_drop to drop.
clear wa_drop.
wa_drop-handle = '1'.
wa_drop-value = 'Admin'.
append wa_drop to drop.
clear wa_drop.
wa_drop-handle = '1'.
wa_drop-value = 'NSS'.
append wa_drop to drop.
clear wa_drop.
wa_drop-handle = '1'.
wa_drop-value = 'Finance'.
append wa_drop to drop.
clear wa_drop.
call method grid->set_drop_down_table
EXPORTING
it_drop_down = drop.
endform.
*& Module set_gui OUTPUT
* text
MODULE set_gui OUTPUT.
set pf-status 'PF_GUI'.
ENDMODULE. " set_gui OUTPUT -
Reading a csv file and bind to a data grid
hi. doing a school project and been searching. the application reads a csv file from c:\stocklist.csv, and then this in a button called btnLoadData, and now need to read in a data control called DmgDisplayData. do i put the code in the button, or in the
data grid. been searching, but cannot seem to find any thing. so, where do i put the code, in the data control, and does any one have an example code how to read into the data fields. also need to have one field, able to edit, the other three or four fields,
read only. can any one help me out. never covered this in the subject, but did do file streams a few years ago in vb, but usin g c#,a dn the help in visual studio, not that helpful, with a blind person using a screen reader, jaws for windows from http://www.freedomscientific.com,
and using visual studio 2013 community edition. can any one help me out, been searching and trawling about 15 to 20 pages so far, and did try a couple of sites, but could not find, any help. thanks. the application is to read a csv file from a button, and
load into a data grid, then have a message box, saying file load successful, then have one field, order on as edit, but the other fields, read only, so do i need the navigator buttons, for next, back, previous, etc, and how do i code that as well. not to do
it for me, want to learn, but maybe some sample code, did do navgiator controls, years ago for a vb project, but need the c # example for that, thanks. then you have a button, Save data, that saves the csv file in the data grid. so can google for that. then
have a toolbar, with a button saying, Sort Items, a tool strip, and when you click on that button, you have a drop down list, of three items, then a sort button, which will then sort the array in the data grid. so, do i need another form, or just do the combo
box as an invisible control, then just refrence, that in the toolbar. so need to use th file class and an array, learnt about single and multi arrays. any ideas. thanks.
http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOzHi Marvin,
-->where do i put this, in the data grid click event. or in the form load event. thanks.
You could use this code after you initialize the DataGridView. you could put it in the form load event.
-->what about how get the tool bar and the combo box and another button, then sort from the combo box on the array for the collumns, for to set focus to the first read collumn for the data grid. how do i do that, close the parent form, and have another
form on the toolbar.
Since this is another issue of this thread, I would recommend you posting it with
another thread. We will focus on that thread to help you. Thanks for your
understanding.
BTW, Before you asking questions, I suggest you could learn to make it by yourself. You could begin to learn winforms in MSDN articles:
https://msdn.microsoft.com/en-us/library/dd30h2yb%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396. Or Google it, you will get many answers. In that way, you will learn more from the questions.
Best regards,
Youjun Tang
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
HELP: XML or Data Grid failing from server
Help,
I am working a proof-of-concept flash function for a client
that reads an XML file into a data grid. As coded, it works great
when I run it locally, but when I transfer it to the web server it
doesn't work (grid object shows but no data). And I guess I don't
understand remote debugging because when I "Begin remote debugging
session" and then "Open from site" it appears to download and
again, runs fine.
The the remote SWF is located at
http://www.gw-webs.com/TSI/teamTSI.SWF.
The XML and HTML are also located in the same remote folder.
The code is all in Frame 1 of the file (not in a movie clip):
_global.nameAR = new Array;
_global.titleAR = new Array;
_global.biographyAR = new Array;
_global.contactAddressAR = new Array;
_global.contactPhoneAR = new Array;
_global.contactEmailAR = new Array;
_global.pictureFileAR = new Array;
_global.ARindex = 0;
hd_name._visible = false;
hd_title._visible = false;
hd_biography._visible = false;
hd_phone._visible = false;
hd_email._visible = false;
hd_mail._visible = false;
function processXMLData(xml:XML)
var i :Number = 0;
var num:Number = xml.firstChild.childNodes.length;
for (var i = 0; i < num; i++) {
_global.nameAR
=
xml.firstChild.childNodes.childNodes[0].childNodes[0].nodeValue;
_global.titleAR
=
xml.firstChild.childNodes.childNodes[1].childNodes[0].nodeValue;
_global.biographyAR
=
xml.firstChild.childNodes.childNodes[2].childNodes[0].nodeValue;
_global.contactAddressAR
=
xml.firstChild.childNodes.childNodes[3].childNodes[0].nodeValue;
_global.contactPhoneAR
=
xml.firstChild.childNodes.childNodes[4].childNodes[0].nodeValue;
_global.contactEmailAR
=
xml.firstChild.childNodes.childNodes[5].childNodes[0].nodeValue;
_global.pictureFileAR
=
xml.firstChild.childNodes.childNodes[6].childNodes[0].nodeValue;
var dataAR = new Array;
for (i = 0; i < num; i++) {
dataAR
= ({Name: _global.nameAR, Title: _global.titleAR
dg_team.dataProvider = dataAR;
var xmlData=new XML();
System.useCodepage = true;
xmlData.ignoreWhite=true;
xmlData.onLoad = function(ok:Boolean) {
if (ok) {
processXMLData(this);
} else {
trace("XML did not load");
// Create data grid click listener object
var dgListener:Object = new Object();
dgListener.cellPress = function(evt_obj:Object) {
i = evt_obj.itemIndex;
if (_global.nameAR <> null) {
hd_name._visible = true;
tx_name.text = _global.nameAR
else {
hd_name._visible = false;
tx_name.text = "";
if (_global.titleAR <> null) {
hd_title._visible = true;
tx_title.text = _global.titleAR
else {
hd_title._visible = false;
tx_title.text = "";
if (_global.biographyAR <> null) {
hd_biography._visible = true;
tx_biography.text = _global.biographyAR
else {
hd_biography._visible = false;
tx_biography.text = "";
if (_global.contactPhoneAR <> null) {
hd_phone._visible = true;
tx_phone.text = _global.contactPhoneAR
else {
hd_phone._visible = false;
tx_phone.text = "";
if (_global.contactEmailAR <> null) {
hd_email._visible = true;
tx_email.text = _global.contactEmailAR
else {
hd_email._visible = false;
tx_email.text = "";
if (_global.contactAddressAR <> null) {
hd_mail._visible = true;
tx_mail.text = _global.contactAddressAR
else {
hd_mail._visible = false;
tx_mail.text = "";
xmlData.load("teamTSI_en.xml");
// Add listener.
dg_team.addEventListener("cellPress", dgListener);
stop();1. your link is 404.
2. use the attach code option to display code: your code in
mangled and difficult to read
3. when using the "new" constructor you should use
parentheses following the class name. (eg, _global.nameAR = new
Array(); )
4. the usual problem is asynchronous (and delayed) loading
when an application is placed online. that doesn't appear to be
your problem, but it's difficult to read your code and quickly spot
that. the 2nd most common problem would be a typo. (eg,
"teamTSI_en.xml" should be "teamTSI_EN.xml" ) -
How to click on linkbuttons in the rows of a data grid
I'm trying to write automation test cases for a flex application using Flex Selenium.
The flex selenium API provides only 2 click events: click(String objectId) and click(String objectId, String optionalButtonLabel)
There are no click events for rows or columns for a data grid.
The application has a DataGrid with 2 linkbuttons in a column for each row (besides other columns).
The linkbuttons have an id. But clicking it only clicks the one in the first row.
Now, I have to perform these tasks:
- Click on the link buttons in any row
- Click on any row
- Click on column header to sort
How can I accomplish these?Hi Suman,
thanks for your prompt reply.
I am trying it but it doesn't work. I started to run the query for a while but it is still running and there is no result for it. I still see the variable popup I filled after the first running of the query.
Any other idea?
Kind regards,
Ali -
ALV GRID - double click event - hot spot event
Dear developers
I am building a custom application using ALV GRID (OO method).
I have three ALV's on the screen.
User selects a cell on the first ALV from the list. say a specific product group.
The second ALV displays the product records depnding on selection of first ALV. (this works fine).
when the user selects a cell of a specific column on ALV grid 2 using double click event or hotspot I am always getting row ID as 1 , irrespective of the user clickin on row 2 or 3 on the specific cell.
To carry out further processing , I need to get the exact row the user is selecting which I expected to be available in LVC_S_ROID. My further process works always with ROW ID as 1.
I am using event hot spot in alv grid 1. In grid 2 I tried both hot spot and double click . But both returns the index value of row as 1 , irrespective of the cell being clicked is beyond row 1. in second grid.
Looking forward for help or suggestion on this,
Regards
KumarHi
The handler is implemented as follows for all ALV GRIDs.
I give below only the relevant one grid 2 from my code.
Class definition
**03/17/2005 skulist hotspot
handle_skulist FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no,
Class implementation
**03/17/2005 sku list by currency hotspot on listprice
METHOD handle_skulist .
PERFORM handle_skulist USING e_row_id e_column_id es_row_no.
ENDMETHOD. "HANDLE_HOTSPOT_CLICK
DATA gr_event_handler TYPE REF TO lcl_event_handler.
DATA gr_event_handler_4 TYPE REF TO lcl_event_handler.
The above are done in an include and are public in nature.
Also note that I have similar implementation for similar events for grid 1 bu the event handlers are registered in different names.
The code below is in the maib program , under a custom container for grid 2
CREATE OBJECT gr_event_handler_4.
SET HANDLER gr_event_handler_4->handle_skulist FOR gr_alvgrid1.
*Based on the user action on grid 2 this form is getting executed. But as I said earlier the parameter I am getting for index is 1 always.
FORM handle_skulist USING i_row_id1 TYPE lvc_s_row
i_column_id1 TYPE lvc_s_col
is_row_no1 TYPE lvc_s_roid. -
Hi there,
I am a beginner in Visual Basic Express 2010. I have a Point of Sale program that uses DataGridView to display records from an external microsoft access
database using the fillby query.
It works, but it repopulates the same row each time, but i want to be able to display multiple records at the same time, a new row should be filled for
each click of the fillby button.
also I want to be able to delete any records if the customer suddenly decides to not buy an item after it has already been entered.
so actually 2 questions here:
1. how to populate a new row for each click of the fillby button
2. how to delete records from data grid view after an item has been entered
Thanks
VishwasHello,
The FillBy method loads data according to what the results are from the SELECT statement, so if there is one row then you get one row in the DataGridView, have two rows then two rows show up.
Some examples
Form load populates our dataset with all data as it was defined with a plain SELECT statement. Button1 loads via a query I created after the fact to filter on a column, the next button adds a new row to the existing data. When adding a new row it is appended
to the current data displayed and the primary key is a negative value but the new key is shown after pressing the save button on the BindingNavigator or there are other ways to get the new key by manually adding the row to the backend table bypassing the Adapter.
The following article with code shows this but does not address adapters.
Conceptually speaking the code in the second code block shows how to get the new key
Public Class Form1
Private Sub StudentsBindingNavigatorSaveItem_Click(
sender As Object, e As EventArgs) Handles StudentsBindingNavigatorSaveItem.Click
Me.Validate()
Me.StudentsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MyDataSet)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MyDataSet.Students' table. You can move, or remove it, as needed.
Me.StudentsTableAdapter.Fill(Me.MyDataSet.Students)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.StudentsTableAdapter.FillBy(Me.MyDataSet.Students, ComboBox1.Text)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.MyDataSet.Students.AddStudentsRow("Jane", "Adams", "Female")
End Sub
End Class
Get new key taken from
this article.
Public Function AddNewRow(ByVal sender As Customer, ByRef Identfier As Integer) As Boolean
Dim Success As Boolean = True
Try
Using cn As New OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
Using cmd As New OleDb.OleDbCommand With {.Connection = cn}
cmd.CommandText = InsertStatement
cmd.Parameters.AddWithValue("@CompanyName", sender.CompanyName)
cmd.Parameters.AddWithValue("@ContactName", sender.ContactName)
cmd.Parameters.AddWithValue("@ContactTitle", sender.ContactTitle)
cn.Open()
cmd.ExecuteNonQuery()
cmd.CommandText = "Select @@Identity"
Identfier = CInt(cmd.ExecuteScalar)
End Using
End Using
Catch ex As Exception
Success = False
End Try
Return Success
End Function
In closing I have not given you a solution but hopefully given you some stuff/logic to assist with this issue, if not perhaps I missed what you want conceptually speaking.
Additional resources
http://msdn.microsoft.com/en-us/library/fxsa23t6.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
Handling Right & Left Click Events in ALV Grid
Hi Friends,
Please give me the idea how to handle Right & Left mouse Click Events in ALV Grid.
My requirement is that when i click on the grid i need to pop up a message.
Eagerly waiting for your replies
Thanks
Satishyou have to Define a class and implement event handler methods for this purpose.
and the following events can help.
LEFT_CLICK_DESIGN
LEFT_CLICK_RUN
Regards
Raja -
SharePoint JS grid paging, capturing values using single click event
Hi
I need some help with getting the following work using the SharePoint JS grid, the reference articles available are not sufficient to continue work.
1) Setting up Paging
2) Capturing individual field values on single click or any other relevant event.
Sample code or references would be of great help.
References
http://msdn.microsoft.com/en-us/library/office/ee535898(v=office.14).aspx
http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010programming.aspx?ID=d6e32632-d0e4-4337-95c3-c2d06fc3ef86
http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010programming.aspx?ID=5c952c6d-b2be-4563-b805-b00e7c8136ff
http://msdn.microsoft.com/en-us/library/ff681039.aspx
http://social.msdn.microsoft.com/Forums/en-US/a439fcc2-42de-45ca-9f74-935498e0d246/js-grid-oncelleditcompleted-event-infinitely-fired?forum=project2010custprog
Thanks,
Sharat
Sharat Menon (Sharepoint Developer)Hi,
Please try to use PagingFilter class to achieve paging in JS Grid.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.jsgrid.pagingfilter.aspx
Here is a similar thread for you to take a look at:
https://go4answers.webhost4life.com/Example/sharepoint-jsgrid-2692.aspx
If you want to implement more complex functionalities for a list, I suggest you use SPGridView to achieve it.
Best regards
Dennis Guo
TechNet Community Support -
Click event on a item renderer stops data being passed
Hi
I'm trying to create a item renderer based on a Canvas, this renderer is then used in a List component. I'm trying to get a click event fired when the user clicks on one of the items in the List. I'm also formatting the data being passed into the item renderer to do this I'm overriding the set data property like this:
override public function set data(value:Object):void
title.text = value.marketName;
sellPrice.text = value.sellPrice;
buyPrice.text = value.buyPrice;
change.text = value.percentageChangeOnDay;
var i:String = "-";
if(String(value.percentageChangeOnDay).indexOf(i))
change.styleName = "PositiveChange";
else
change.styleName = "NegativeChange";
When I add a click event to my item renderer like this,
<view:DisplayItem click="itemClickedEvent( event )" />
I get a null reference error in my set data function. If I remove the click event the data is passed correctly, I've also found that if I use a rollOut event like this,
<view:DisplayItem rollOut="rolledOverEvent( event )"/>
the data is passed fine and the event works too, it seems that click events cause the data not to be passed.
Why does having a click event cause this problem? How can I have a click event on the item renderer and still format my data?
Cheers
StephenFound out that I can use the itemClick event of the List component I'm using my item renderer in, so really my item renderer does not need a click event.
-
Data Grid Right click menu customize
Hi All,
i need to change the data grid right click menu customize the background color,background mouse over color, Text color, Text hover color . can any one help me this
Regards
Rajeshcat14 wrote:
> Any idea on how to customize right click menu?
> I've seen some site could show the company name.
>
> Pls advice.
You can check Help for "ContextMenu" to get details info,
meantime
simple example of getting a link to author's site:
var my_cm:ContextMenu = new ContextMenu();
var menuItem_cmi:ContextMenuItem = new ContextMenuItem("Made
by Yahoo", onSelection);
my_cm.customItems.push(menuItem_cmi);
function onSelection(obj, menuItem) {
trace("You just selected " + menuItem.caption);
getURL("
http://www.yahoo.com", "_blank");
this.menu = my_cm;
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Extract all the data grids in one click
Hi All,
I need to download all the data forms that i have in the system.
We have a fat hierarchy and i'm looking for a short way to extract all the data grids without extracting from every folder in the hierarchy separately.
I don't care about the type of the file/files. it can be one long file...
Do you know what action i can perform here?
Thanks,
OritHi,
What operating system are you using? What version of Excel are you using? It's possible you are using a version of Excel we do not support. Also, can you send me an email with your exported Excel file, so I can try opening it myself? My email address is [email protected]
Thanks,
Todd -
How to stored data after clicking checkbox save in database table
TYPE-pools: slis.
tables:mkpf,mseg,mard,COWB_COMP.
TYPES: BEGIN OF tp_data,
mblnr LIKE mseg-mblnr,
matnr LIKE mseg-matnr,
werks LIKE mard-werks,
lgort LIKE mard-lgort,
lgpbe LIKE mard-lgpbe,
charg LIKE mseg-charg,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
kostl LIKE mseg-kostl,
aufnr LIKE mseg-aufnr,
rsnum LIKE mseg-rsnum,
endkz like COWB_COMP-endkz,
END OF tp_data,
tp_tbl_data TYPE STANDARD TABLE OF tp_data.
*data: t_data like ztable occurs 0 with header line.
Constants
Data objects (variable declarations and definitions)
Report data to be shown.
DATA: it_data TYPE STANDARD TABLE OF tp_data.
Heading of the report.
DATA: t_heading TYPE slis_t_listheader.
========================== Selection Screen ==========================
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:smblnr FOR mseg-mblnr MODIF ID m1,
smatnr FOR mseg-matnr MODIF ID m2,
swerks FOR mard-werks MODIF ID m3,
slgort FOR mard-lgort MODIF ID m4,
slgpbe FOR mard-lgpbe MODIF ID m5,
scharg FOR mseg-charg MODIF ID m6,
sbwart FOR mseg-bwart MODIF ID m7,
skostl FOR mseg-kostl MODIF ID m8,
saufnr FOR mseg-aufnr MODIF ID m9,
srsnum FOR mseg-rsnum MODIF ID m10.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS:pre RADIOBUTTON GROUP radi USER-COMMAND ucomm DEFAULT 'X',
pse RADIOBUTTON GROUP radi,
bps RADIOBUTTON GROUP radi.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
PARAMETER:layout TYPE i.
SELECTION-SCREEN END OF BLOCK b3.
=========================== Event Blocks =============================
AT selection-SCREEN.
start-OF-selection.
PERFORM get_data USING it_data.
END-OF-selection.
PERFORM build_alv USING it_data t_heading.
=========================== Subroutines ==============================
*& Form get_data
Gets the information to be shown in the report.
FORM get_data USING t_data TYPE tp_tbl_data.
SELECT msegmblnr msegmatnr mardwerks mardlgort mardlgpbe msegcharg msegbwart mkpfbudat
msegmenge msegmeins msegkostl msegaufnr mseg~rsnum
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM mseg
JOIN mard ON mardmatnr EQ msegmatnr
JOIN mkpf ON msegmblnr EQ mkpfmblnr
WHERE mseg~matnr IN smatnr.
ENDFORM. " get_data
*& Form build_alv
Builds and display the ALV Grid.
FORM build_alv USING t_data TYPE tp_tbl_data
t_heading TYPE slis_t_listheader.
ALV required data objects.
DATA: w_title TYPE lvc_title,
w_comm TYPE slis_formname,
w_status TYPE slis_formname,
x_layout TYPE slis_layout_alv,
t_event TYPE slis_t_event,
t_fieldcat TYPE slis_t_fieldcat_alv,
t_sort TYPE slis_t_sortinfo_alv.
REFRESH t_fieldcat.
REFRESH t_event.
REFRESH t_sort.
CLEAR x_layout.
CLEAR w_title.
Field Catalog
PERFORM set_fieldcat2 USING:
1 'MBLNR' 'MBLNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
2 'MATNR' 'MATNR' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
3 'WERKS' 'WERKS' 'MARD' space space space space space space space space space space space space t_fieldcat,
4 'LGORT' 'LGORT' 'MARD' space space space space space space space space space space space space t_fieldcat ,
5 'LGPBE' 'LGPBE' 'MARD' space space space space space space space space space space space space t_fieldcat ,
6 'CHARG' 'CHARG' 'MSEG' space space space space space space space space space space space space t_fieldcat ,
7 'BWART' 'BWART' 'MSEG' space space space space space space space space space space space space t_fieldcat,
8 'BUDAT' 'BUDAT' 'MKPF' space space space space space space space space space space space space t_fieldcat,
9 'MENGE' 'MENGE' 'MSEG' space space space space space space space space space space space space t_fieldcat,
10 'MEINS' 'MEINS' 'MSEG' space space space space space space space space space space space space t_fieldcat,
11 'KOSTL' 'KOSTL' 'MSEG' space space space space space space space space space space space space t_fieldcat,
12 'AUFNR' 'AUFNR' 'MSEG' space space space space space space space space space space space space t_fieldcat,
13 'RSNUM' 'RSNUM' 'MSEG' space space space space space space space space space space space space t_fieldcat,
14 'ENDKZ' 'ENDKZ' 'COWB_COMP' space space 'select' 'Select this row' 'Sel' 'Select this row' space space space 'X' 'X' space t_fieldcat.
Layout
x_layout-zebra = 'X'.
Top of page heading
PERFORM set_top_page_heading USING t_heading t_event.
Events
PERFORM set_events USING t_event.
GUI Status
w_status = ''.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
PERFORM set_order USING 'MBLNR' 'IT_DATA' 'X' space 'X' t_sort.
PERFORM set_order USING 'EBELN' 'IT_DATA' 'X' space 'X' t_sort.
PERFORM set_order USING 'EBELP' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
TABLES
t_outtab = t_data
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
FORM set_top_page_heading USING t_heading TYPE slis_t_listheader
t_events TYPE slis_t_event.
DATA: x_heading TYPE slis_listheader,
x_event TYPE LINE OF slis_t_event.
Report title
CLEAR t_heading[].
CLEAR x_heading.
x_heading-typ = 'H'.
x_heading-info = 'Reporte Prueba'(001).
APPEND x_heading TO t_heading.
Program name
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Program: '.
x_heading-info = sy-repid.
APPEND x_heading TO t_heading.
User who is running the report
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'User: '.
x_heading-info = sy-uname.
APPEND x_heading TO t_heading.
Date of execution
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Date: '.
WRITE sy-datum TO x_heading-info.
APPEND x_heading TO t_heading.
Time of execution
CLEAR x_heading.
x_heading-typ = 'S'.
x_heading-KEY = 'Time: '.
WRITE sy-uzeit TO x_heading-info.
APPEND x_heading TO t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-FORM = 'TOP_OF_PAGE'.
APPEND x_event TO t_events.
ENDFORM.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
FORM set_events USING t_events TYPE slis_t_event.
DATA: x_event TYPE LINE OF slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
ENDFORM.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-UP = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
FORM set_fieldcat2 USING p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-HOTSPOT = p_hotspot.
wa_fieldcat-CHECKBOX = p_checkbox.
wa_fieldcat-ICON = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given is a data element.
If p_ref_tabname is given, the ref_fieldname given is a field of a table. In case ref_fieldname is not given, it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF p_edit IS NOT INITIAL.
wa_fieldcat-INPUT = 'X'.
wa_fieldcat-EDIT = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
=========================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'XXXXX'
it_list_commentary = t_heading.
ENDFORM. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
ENDFORM. "user_command
this is my code, how to store data after clicking checkbox in databasetable,
how to write that cide.
plz send me code.hi!,
use MODIFY to update data into the data base table.
regards
anjali -
ALV: Issue with double click event after sorting the ALV
Hello Experts,
I have an internal table that populates an ALV grid. When the user doubleclicks a row, my method HANDLE_DOUBLE_CLICK returns the e_row-index value from the ALV Grid. I use this index value to read the internal table, then retrieve additional data.
My problem is the user may sort the ALV grid before double clicking on a line. If this happens my internal table is not sorted to match the ALV grid, so reading the internal table with the e_row-index value returns the wrong information.
When the double click event occurs, is it possible to capture the value in column 1 instead of a value for e_row-index?
There is one more paramter in HANDLE_DOUBLE_CLICK for row id. It is coming blank in debugging . what is the purpose of this parameter and how i can make use of it ?
Regards
VivekHi,
I am Posting The Code Which Uses Double Click Event.
And This Code will provide the total information to you.
REPORT ZALVGRID_PG.
TABLES: SSCRFIELDS.
DATA: V_BELNR TYPE RBKP-BELNR.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: IRNO FOR V_BELNR.
PARAMETERS: P_GJAHR TYPE RBKP-GJAHR.
SELECTION-SCREEN END OF BLOCK B1.
DATA: WA TYPE ZALVGRID_DISPLAY,
ITAB TYPE STANDARD TABLE OF ZALVGRID_DISPLAY.
DATA: IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: L_IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: L_TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.
TYPE-POOLS: SLIS,SDYDO.
DATA: L_LOGO TYPE SDYDO_VALUE,
L_LIST TYPE SLIS_T_LISTHEADER.
END-OF-SELECTION.
CLASS CL_LC DEFINITION.
PUBLIC SECTION.
METHODS: DC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN.
ENDCLASS.
CLASS CL_LC IMPLEMENTATION.
METHOD DC.
DATA: WA1 TYPE ZALVGRID_DISPLAY.
READ TABLE ITAB INTO WA1 INDEX E_ROW-INDEX.
BREAK-POINT.
SET PARAMETER ID 'BLN' FIELD WA1-BELNR.
CALL TRANSACTION 'FB02'.
ENDMETHOD. "DC
ENDCLASS.
DATA: OBJ_CL TYPE REF TO CL_LC.
START-OF-SELECTION.
PERFORM SELECT_DATA.
IF SY-SUBRC = 0.
CALL SCREEN 100.
ELSE.
MESSAGE E000(0) WITH 'DATA NOT FOUND'.
ENDIF.
INCLUDE ZALVGRID_PG_STATUS_0100O01.
INCLUDE ZALVGRID_PG_LOGOSUBF01.
INCLUDE ZALVGRID_PG_SELECT_DATAF01.
INCLUDE ZALVGRID_PG_USER_COMMAND_01I01.
***INCLUDE ZALVGRID_PG_STATUS_0100O01 .
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'AB'.
* SET TITLEBAR 'xxx'.
IF IDENTITY IS INITIAL.
CREATE OBJECT IDENTITY
EXPORTING
CONTAINER_NAME = 'ALVCONTROL'.
CREATE OBJECT GRID
EXPORTING
I_PARENT = IDENTITY.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'ZALVGRID_DISPLAY'
CHANGING
IT_OUTTAB = ITAB.
CREATE OBJECT OBJ_CL.
SET HANDLER OBJ_CL->DC FOR GRID.
ENDIF.
IF L_IDENTITY IS INITIAL.
CREATE OBJECT L_IDENTITY
EXPORTING
CONTAINER_NAME = 'LOGO'.
CREATE OBJECT L_TREE
EXPORTING
I_PARENT = L_IDENTITY.
PERFORM LOGOSUB USING L_LOGO.
CALL METHOD L_TREE->CREATE_REPORT_HEADER
EXPORTING
IT_LIST_COMMENTARY = L_LIST
I_LOGO = L_LOGO.
ENDIF .
ENDMODULE. " STATUS_0100 OUTPUT
***INCLUDE ZALVGRID_PG_LOGOSUBF01 .
FORM LOGOSUB USING P_L_LOGO.
P_L_LOGO = 'ERPLOGO'.
ENDFORM. " LOGOSUB
***INCLUDE ZALVGRID_PG_SELECT_DATAF01 .
FORM SELECT_DATA .
SELECT RBKP~BELNR
RBKP~BLDAT
RSEG~BUZEI
RSEG~MATNR
INTO TABLE ITAB
FROM RBKP INNER JOIN RSEG
ON RBKP~BELNR = RSEG~BELNR
WHERE RBKP~BELNR IN IRNO
AND RBKP~GJAHR = P_GJAHR.
ENDFORM. " SELECT_DATA
***INCLUDE ZALVGRID_PG_USER_COMMAND_01I01 .
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'CANCEL'.
EXIT.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
Warm Regards,
PavanKumar.G
Edited by: pavankumar.g on Jan 19, 2012 5:30 AM -
Sort functionality in Data Grid
Hi Gurus,
I am new to this DataGrid control.I want to establish the sort functionality when clicking on the headercolumns as in matrices.
(ie.When double clicking the header column , sort the data in ascending or descending order of that column) like in system form matrices.
How ever this is not possible when I tried with grid control.
The problem I am facing is that I cannot get the column headers of the grid programmatically.(in duble click event or itempressed event)
Anybody did this one previously? Also how
we can change the column order of the grid using screen painter?
The columns that actually come visible in the grid are actually columns of the linked datatable object.
In the designer ,there is no "swap" button for column re-ordering.
Only one way I know is changing the query associated with datatable.
This is a crucial thing ,since client may ask for re-ordering of columns frequently.
Can anybody help?
Regards,
DeepeshHi Deepesh,
1. This functionality is not available with the SDK. Thus it's not possible to change it on the fly. Your only option is to change the query associated with datatable (as you mentioned). You may set up a user preference table, that the user can configure with its preference. That's the best you can do.
2. To swap the columns in screen painter you must use SBO 2005 (it's not available on previous release). What you must do is, click on the one column you want to swap and the other you want to swap and click on the swap button (on the left bottom of the page in the columns tab)
Maybe you are looking for
-
I have multi email accounts in TB but all mail goes to one account...Why?
I have multiple email accounts in TB on my MAC but all the email goes to the first account listed. These are not my real account names but here is an Example: [email protected] [email protected] [email protected] All email goes to the [email protecte
-
HI, When I upload photos from my Canon Rebel 1000D to iphoto the images are labelled JPEG, yet I shoot in RAW.How do I get iphoto 11 vers9.1.3 to not convert the photos to jpeg. I seem to have tried and read so much but just can't figure it out. How
-
hi, 1. Can anyone suggest me how to call a dll in a bsp. if you can help me with a sample code it'll be helpful. 2. Is it possible to call VBScript in BSP Thnx in Advance Vinodh
-
I just bought one of these things off eBay, but it doesn't seem to be working with my TV. When I plug it into the iBook, the iBook screen with fade into a blue color (which would make me think it's detecting it), and then comes back with what I was d
-
I am loading an external .swf file onto my stage. This is the script I am using: createEmptyMovieClip("village_holder", 1); village_holder.loadMovie(url, 0); onEnterFrame = function() { var bytes_loaded = village_holder.getBytesLoaded(); var bytes_to