How to find unsaved rows in a free-jqgrid? - free-jqgrid

This may be a strange question. But I encounter such a situation in my implementation. I have three free-jqgrid implementation in a single page. And I have, say 5 records in each. In the first grid, I open row number 2 for editing, do some modification to the columns but didn't click on save-icon to save the changes.
Then I jump to the second grid and open up say row number 4 for editing and make some modifications and don't save that also.
After all the grids, I have a button(say, a "Save" button) at the bottom of the page. Once this button is clicked, I need to validate the above grids and show a validation message that "You have some unsaved data in the grids" how to do this in free-jqgrid???
If that is possible, the next requirement is like, I have to save such unsaved data in the grids automatically - (without waiting for the user to click save for each edited row in each grid) to the db. Is it possible with free-jqgrid? If yes, please share me some example or suggest me how shall I achieve this?

This is is just a hint and do not know if in free-jqGrid this is still available.
When the inline editing is on - a grid parameter savedRow (array of objects) stores the original data of the row(s). In case the user cancel editing the row is restored from this parameter and in case of saving it is deleted.
The idea is simple you can check if this this array is not empty to determine which row is in edit mode and in case the user push a external button you can get the id from savedRow parameter and call saveRow methodto save the unsaved data.
I note again - this is just valid if this parameter is still available in free-jqGrid.

Related

Formula help on IF ELSE on Smartsheet

I want to have a condition where IF Delivered column checkbox is checked, then that whole row will be deleted. Is that feasible?
How can I start with it?
Formulas can't change the condition of an item (like a row), only the value in a cell. So, in other words, you can't delete a row with a formula.
You "could" do this with an external script using the Smartsheet API, but you'll want to take situations that #Ken White mentioned in the comments into account. Your script should make sure that there is a way for users to recover the deleted row if the box is checked by mistake.
There are a couple of ways this might be possible. If you set up a default filter on a sheet to always load rows where complete box is unchecked, then, if you checked off a task or two and reloaded the sheet those tasks would not be visible the next time it loads.
To do this:
Create a new filter.
Title it and check the Share Filter checkbox
Set the criteria to the checkbox is unchecked
Then click okay
Save the sheet to save the shared filter.
Click on SHARE
Scroll down and click edit next to the default view
Set the filter to new filter you saved
Save.
Check off some boxes and save the sheet.
Reload the sheet and the completed items will not be visible.

ListView32 - re-adding column doesn't restore data

I'm implementing show/hide column behaviour in a standard C++ Win32 application (no frameworks).
Say we've got 3 columns in a ListView control in Details view. The user has the option to show/hide the last two columns in order to see the extra detail if wanted or hide them to reduce clutter. All works well except that after the columns are deleted and then re-added, the data from the sub-items in those columns doesn't show up again, i.e. the columns are empty.
None of the items themselves have been altered in the meantime - do I lose the sub-item text when I delete the columns or I am missing something to force the columns to redraw the data?
Steps to reproduce:
1) Create a ListView32 control with 3 columns and add a bunch of items (and text to each of the items' sub-items). All good.
2) The user clicks "Hide Details", so I use LVM_DELETECOLUMN twice to remove the last two columns and they disappear. All good.
3) The user clicks "Show Details", so I use LVM_INSERTCOLUMN to add the last two columns and the headings appear, but the columns themselves are empty.
As an alternative, setting the column widths to zero is a hack and the user can still grab the re-size column splitter, so it's not a great option.
Many thanks for any suggestions.
Typically one does not store data in GUI. In case of plain listview32 you should add items specifying LPSTR_TEXTCALLBACK instead of real text and then handle LVN_GETDISPINFOW notification supplying (sub)item data. Windows will send this notification for all items. You can force Windows to retrieve data again by sending LVM_UPDATE message.
Setting the column widths is a viable solution. That is the way I do it in my UIs when columns can be shown and hidden dynamically. It works fine.
To prevent the user from resizing "hidden" columns, simply subclass the ListView using SetWindowLongPtr(GWL_WNDPROC) or SetWindowSubclass() to intercept HDN_BEGINTRACK notifications from the ListView's header control:
Notifies a header control's parent window that the user has begun dragging a divider in the control (that is, the user has pressed the left mouse button while the mouse cursor is on a divider in the header control). This notification code is sent in the form of a WM_NOTIFY message.
...
Returns FALSE to allow tracking of the divider, or TRUE to prevent tracking.

How to do dynamic paging in Grid.MVC

I have using grid.mvc control in my project. I want to use dynamic paging in grid.mvc control.
I have combobox having entries 10,25,50. when I change comboBox value. Grid should display data accordingly. ( E.g. when I select 25, grid will show 25 rows). by deafult grid is showing 10 rows at a time.
Also it should adjust while filtering records.
I tried but didn't found any suitable solution.
This in theory should be pretty easy though I haven't done it myself.
You can link that dropdown (in the view) to an action result (in the controller) that changes a value you pass to the ViewBag (in controller ViewBag.WhateverName = dropdown's value).
Then re-render the same view and in the place when you end your grid, end it with
}).WithPaging(ViewBag.WhateverName)
Basically .WithPaging(10) would give you pages with 10 rows, WithPaging(20) 20 rows per page, etc. So by changing that value with the dropdown and registering that action in the controller to reassign the value, you should be able to achieve this functionality.
I will keep editing and maybe add controller code later if I have time, just wanted to get something up to help you out. Good luck!

Making a Row Read Only in a tabular form based on table value

I have a tabular form which is updated throughout the year and i wanted to prevent users from editing certain rows. Currently the 'row type' is hard coded however I want the application admin to control which 'row types' are readable / write at certain times. My answered question, click here.
Currently a dynamic action is fired which prevents the rows that contain the type 'manager figure' and 'sales_target' being edited.
I have created a table with the three row types against each customer. Each status is set by a number: 0 to 3 (These i will decode into something meaningful for users).
0 - Row with that row type is read only.
1 - Users can enter into the row with that row type.
2 - row is read only with that row type.
3 - row is complete and set to read only.
I have created a new form (new tab) for the admin user to maintain each status.
Currently for Customer 'Big Toy Store' rows should be set as follows:
Manager Figure row should be read only (since set to 2)
Sales should be readable (since set to 0)
Sales target should be writable (since set to 1)
Please can i be pointed in the right direction, ive looked into jquery but struggling to work out how to pass the output of an sql query to it, so it can be used to determine which rows should be read only.
Link:apex.oracle.com
workspace: apps2
user: developer.user
password: DynamicAction
application name: Application 71656 Read only Rows for Tabular Form
I'm not sure that a tabular form is a good format to work out this idea. As you can see, you require quite a bit of javascript to produce the results you want. Not only that, but this is all client side too, and thus there are some security risks to take into account. After all, I could just run some Firebug and disable or revert all things you did, and even change the numbers. Especially with sales figures, which is something you most definitely do want altered by everybody and is also the nature of your question, security is important.
There are more elegant ways here for you to control this, and not in the least to reduce the amount of highly customized javascript code. For example, you could do away with the tabular form, and instead implement a modal popup from an interactive report. Since the modal popup would be an iframe and thus a different page, you can create a form page. On a form page you have a lot more control over what happens to certain elements. You can specify conditions, read-only conditions, or use authorization schemes. All things you can not evidently use in a tabular form.
I'd think you'd do yourself a service by thinking this over again, and explore a different option. How much of a dealbreaker is using a tabular form actually?
You need the user. You need to know what group he belongs to, and then this has to be checked against the different statusses and rows have to be en/disabled. Do you really want this to happen on the client side?
I'm not saying it can't be done in a tabular form and javascript. It can, I'm just really doubting this is the correct approach!

How to seek stmt to row number in SQLite3?

I don't find the way to seek in a sqlite3_stmt.
I have an input view to let user input and execute SQL, but maybe the result has a huge amounts of records. I just want to display a piece of the result.
E.g.: I have 20000 rows in stmt. But I want to display the first 2000 rows (0-2000). When the user clicks the next button, I want to display the second 2000 rows (2000-4000). When the user click the previous button, I want the display to rewind. So I want seek in the stmt. But I cannot find some SQLite3 function to seek the stmt.
I use the C/C++ interface.
SQLite computes the returned values of a statement on the fly.
The only way to move to another row is to call sqlite3_step; it is not possible to move backwards.
You could read all rows and save them somewhere, but this becomes inpractical when there are too many of them.
You could execute separate queries with the LIMIT/OFFSET clause to restrict the result to the current window.
However, this becomes inefficient when the offset value becomes bigger because SQLite still has to compute all those records.
To implement a scrolling cursor, you should save the last(/first) record of the page, and ask the database to return the next(/previous) 2000 records after(/before) that record.
This is explained in detail in the SQLite wiki.