jqGrid issue - getRowData - jqgrid

I seem to be havign yet another problem with jqGrid :-( I am trying to get the current row data using getRowData, but all I get back is an array [object, Object]. What am I doing wrong?
This is what I'm using
var rowdata = $("#list").jqGrid('getRowData');
Can somebody help?
thanks

After reading in the comments additional information about your problem I would recommend you following.
If you need to print the page which contains jqGrid you could need to prepare additional CSS for media="print". See here for additional information.
The method getRowData called without parameters give back the array of rows which are array of visible cells. For every cell will be called unformatter, so the data could be not identical to to data which you posted to jqGrid. Moreover if you use data paging or filtering you can have another problem: only visible cells from the current page will be returned back.
I personally prefer to use export to Excel instead of printing the pages. In the case I add an custom button in the navigator bar. If the button will be clicked by the user the request to the corresponding MVC controller action will be sent. The server get all data for the corresponding grid from the database and generate XLSX Excel data as stream with respect of Open XML SDK. The corresponding code is not very small, but in the way one can generate perfect Excel file formatted like it is required. In the case you don't need install Microsoft Office on the server side. The user just opens Excel with all data if he/she clicks the "Export to Excel" button in the jqGrid. In Excel there are very good printing possibility. The most users knows Excel very good and can customize the data (hide some columns for example) before printing.
So my suggestion to you to spend some time in implementing export to Excel instead of implementing printing of jqGrid directly.

Related

Export data from a list view using a button

I am building a simple admin-on-rest application. One of the features is the user to export the content from a list view. So far I have two possible approaches in mind.
Export based on the selected filters (my favorite).
Export based on the selected rows from the table using check boxes.
I guess two things are necessary to achieve that:
Be able to render a button somewhere in "list view": would be great to add an "export" button inside the "filters" section. I couldn't find a way to render an "export" button keeping the filters.
That "export" button would be able to get the filters (from the list view filter section) for creating my custom URL for downloading the data. Or if using check boxes, detect the selected rows from the table and export that data.
I have been looking for examples or following other colleagues questions and I coundn't come up with anything similar. Any info/example/project will be much appreciated.
This is quite solvable. The filter is stored in the redux form and can be accessed by any connected component. I am guessing you have an API endpoint available that you can ping with the filter data and that can then generate the file and respond with the file URL.
1) Write a connected button component. This should have a mapStateToProps method to access the current filter data
https://marmelab.com/admin-on-rest/List.html#actions
2) It should also dispatch an action that generates a POST request.
https://marmelab.com/admin-on-rest/Actions.html#using-a-custom-action-creator
IMPORTANTLY: You will have to think about how the file itself will get downloaded. Since you are generating the URL on the fly, it will not be embedded in the model data so you do not have access to it. You might have to hard code a file name and path into your components so clicking will always lead to a download. Though this is not as trivial as it sounds, as the file generation itself will be an async operation. I think clicking this button should lead to a redirect to a page where the download link is displayed.
Just to complement krunal's answer, there's a library called FileSaver that can take a json response and start a file save operation with its content, showing a file save dialog, or even download it directly to a file of your choice.

Changing ASP Included file and saving choice as a cookie

Ok, so I'm in the process of expanding my knowledge and need a step in the right direction, not necessarily an answer.
I am wanting to create a script for my eCommerce site that lets users choose between grid and list view on product listings pages.
The grid view will be called using an included file called "incgridview.asp" - the list view file is called "inclistview.asp".
Upon the user choosing an option from the drop down specifying which type of view they want, the respective file should be called. So if they select grid view, I need to load the incgridview.asp (list view will be loaded by default).
Once the selection is made, I need it to switch the view without reloading the page, and store a cookie for 7 days that remembers their selection. Of course, they would still have the option to switch back to the other view.
So basically I am switching which file is included upon user selection of the drop down. Im thinking maybe I need to use ajax but not sure. Any help is greatly appreciated. Thanks!
EDIT
Ok, so this is what I am trying to use, on my file that actually includes the grid pages. It is throwing up this error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: '[object]'
/productsviewtest.asp, line 59
Dim listgridcookie
listgridcookie = Response.Cookies("atdviewcookie")("viewoption")
Select Case listgridcookie
Case "list"
print"list view"
Case "grid"
print "grid view"
Case Else
Response.Cookies ("atdviewcookie")("viewoption") = "grid"
Response.Cookies ("atdviewcookie").Expires = DATE + 7
Response.Redirect(Request.RawUrl)
End Select
here is a steps on your page load:
1) Check if cookies exists and what values are there, if it does not exists - create one with default value.
2) Based on value from cookies show div which has been loaded with data from proper include file.
3) When/if selection changes create/re-write cookies with expiration time you desire.
All what you need to build is JavaScript based switch to show one element and hide another.
If you like to use AJAX or JQuery - you can do it this way but for my taste it take away challenges of creating something you can be proud of.
This is based on your " page must not be reloaded upon changing selection" statement.

How to access the data on a dropdown list in excel using WIN32OLE

I want to programatically choose one of the options available in a Excel Dropdownlist.
To manipulate the worksheet I'm using win32ole on ruby.
It works well until I try to change the value of the dropdownlist.
I simply don't know how and google has been of no help.
setting a value to a a cell is as simple as worksheet.Cells(x,y).Value=new_value. This is not choosing one of the alternatives available on the dropdownlist and it's not even possible since the cell in question is protected.
The protection doesn't stop me from changin the value manualy via excelso I figure there must be a method or functon somewhere that allows me to simulate this action aswell.
Help in advance for any suggestions.
EDIT:
I'm trying to choose one of the values available in the dropdown list.
I didn't find an api specific for dropdows, but I manage a work around. The data of the dropdown is somewhere in the workbook. Just choose from them and set it to the dropdown cell with "Cells.Value=new_value".
It was a little different for me since my workbook I was working on had some kind of protected custom dropdown but esencially the solution is realizing that the data of the dropdown can be found somwhere else in the workbook.

COLDFUSION CFGRID Datapass with a post

I have a bit of a unique challenge today. I have a client that wants to be able to search for multiple items based on inserts into a cfgrid. Suppose we have the following web form:
A Country selection dropdown
A State Selection dependent AJAX dropdown
A city Selection dependent AJAX dropdown
An ADD Button
----------------------------------------------------
A CFGRID that will populate a row with selections when the user clicks the add button
----------------------------------------------------
And finally, a CLEAR button, and a GO button on the bottom.
The resulting page will then query the database and get some statistics about the cities selected. So, suppose an individual picks USA > Arizona > Scottsdale and USA > Arizona > Flagstaff. The grid below the options will 'save' each selection and reset to their default options, waiting for a user to pick additional options or click on 'GO'.
The resulting page will then generate columns that list some statistics about the communities and highlight the 'best of' between each selected community.
Each time a user selects the ADD button (assuming three criteria are selected) I want the information to be added into a CFGRID that displays the options selected. Then, After the user selects at least one country/city/state option, have all of the data in the CFGRID get passed to another page that does a query from the data selected. In theory, the user could pick as many communities as they want, assuming they are willing to let the database sludge through enough data to get what they want and wait through a 'loading' screen to get it.
I'm having these challenges, in no particular order:
- I have an HTML grid that I must use per client spec (No Java or Flash, must be HTML)
- I have no idea how to get the selected options into the CFGRID. I assume there is some JavaScript I can write that uses some sort of AddRow function to add data into the grid with the add button but cannot seem to find how to it on the interwebs
- After we conquer the above challenge, how do I pass the data from the grid into the results page? I thought about passing one big string or a structure, but I'm not sure how to do that through the URL or posting, nor how to get the data out of the grid. I wonder if I am better off coding some sort of string that gets passed from the options page to the results page with a get method instead of dealing with the stuff in the CFGRID and have the CFGRID serve only as a 'dummy' display container.
- Finally, after the pass is complete, I would need to loop through through the structure and perform a CFQUERY or CFSTOREDPROC on each row of data, then get the statistics I need to display on the results page. I assume this would depend on how I am getting the data from the options selection page to the results page.
THANK YOU ALL!
CFGRID is great to start, but it can be b*tch to customize and extend... Have you tried editable CFGRID with bind? See how far off it is from what you want first. If it turns out to be very far, then you might want to go for a jqGrid and code up some jQuery.
To start, read Using HTML grids and make the cfgrid editable.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7a01.html#WSc3ff6d0ea77859461172e0811cbec22c24-72e0
Once you got that working, look at these provided JS functions that you can use with CFGRID
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS0ef8c004658c1089-6262c847120f1a3b244-8000.html
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSd160b5fdf5100e8f-4439fdac128193edfd6-7f5f.html
If you still demand a bit more, you might need to dig into the underlying ExtJS component. At that point I would rather use jqGrid
I found out that the best way to handle this was by using a SerializeJSON call and a Deserialize JSON call back and forth. By using JavaScript notation we are able to pass a complex JavaScript object (array) between one page and another. This has the value add of not having to worry about sessions timing out and making URLs clickable from one solution to the next.

jqgrid save xml string inside hidden cell problem

I have 2 grids. in both of them i use loadonce:true .
In the first grid i have a cell with an onblur event which
opens a dialog with the second grid.
after i edit the second grid i want to save as xml it's content and
ascribe it to the row of the first grid (the row witch opened the dialog).
In the end i want to generate an xml from the first grid that will
include the xml I generated before in the second grid.
so what is the best way to implement this?
Thank's In Advance.
Depend on how exactly you implement the scenario which you describe you could has any data in the internal data parameter of jqGrid existing always if one use local datatype or loadonce:true in your case.
Direct accessing to the data parameter per jQuery("#grid_id").getGridParam('data') get your reference to the data array. The data array contain all data of the grid (not only the current displayed page) and the data are not yet placed in the <td> element. So the data are unmodified and could contain for example any XML fragments.
UPDATED: To make you easier to understand what I mean I made the small demo. If you double-click on a row you will see the XML data associated with the row.
The "note" column can be hidden. Because all hidden columns exist in grid as HTML markup I made it visible. You can see the difference what can be saved as grid internal data and what can be displayed (also as hidden data).
UPDATED 2: You can consider to use autoencode:true option in your grids.

Resources