Slickgrid id column - javascript

Is there a way to bypass the necessity for an ID column? My goal is to display 100,000+ results dynamically. Currently, the only way I have found to do this is to create an "id" column on the table and then loop through it (which is quite costly). If this is the case, is there a more efficient way of doing this? How can I hide the column when the grid is displayed?

Since the usage of a dataview is causing the unique id requirement, then using a simple array as your data would suffice in removing the restriction.
If the advanced functionality of a dataview is required then you have the option of providing a field/property within the setItems call that will provide/override the id field (the field must be present within each data object and have uniqueness across all the data elements). If you cannot guarantee those two conditions, only two options are left.
customize the source code of the dataview to provide a UUID during the processing of updateIdxById
manually iterate the data and inject a UUID (what you are currently doing)
Regarding the column displaying:
Only those fields for which you have provided a column definition are rendered within the grid. Thus, as long as you don't provide the field in a column definition it will not be rendered. You can see in this example that each data object contains an id property but none of the elements of the columns array has a field that points to that property, as such it does not appear as a column.

Related

How to create page items with dynamic action defined on other item in page in oracle apex

I have a page with multiple text fields and select lists with the list of values. What I want to do is defining a dynamic action on one of the select lists that display numbers and returns same numbers and according to the selected number, I want to create or duplicate another select list in an amount of selected number. Then, after the end-user finish his work, I want to be able to take the selected values of select lists that are created within the dynamic action within the on-submit process.
Example:
In short, I want to create a dynamic action that duplicates the instructor list as many as the selected number of the number of sections list. How can I accomplish this?
If I understood what you are saying, you'd rather switch to a tabular form (or interactive grid, depending on Apex version you use). Using it, you can "Add row" as many times as you want (which would be your "Number of sections") and use the same LoV (i.e. Select List) in every row.
As far as I know (which really isn't that much), Apex isn't capable of doing that "as is". Maybe you can accomplish it the way you want it using some other techniques (blindly guessing & mentioning: JavaScript, Ajax, jQuery or whatever you might need).

How to uniquely identify a table row?

In my app I import a JSON file and then display it in a table. The table has 3 columns.
Two issues with this:
The table also has sorting and CRUD operations, so using the array index for the row key is not best practice.
Similar with above, I am trying to implement the functionality to edit a row, and doing so by index is finicky because they may have shifted from sorting or CRUD.
I came up with some potential solutions, but they all seem weak:
Uniquely identify a row by a combination of its visible columns. This has problems because while it's extremely unlikely there will be duplicate rows for this data set, I suppose it's possible.
Uniquely identify a row by fields that are relatively guaranteed to be unique. For example, each row has a creation date, and since all rows are generated manually in the program, I believe this could function as an ID for uniquely identifying rows? It kinda feels like identifying a row by a date is bad for some reason though.. Not sure.
Uniquely identify a row by a combination of all its fields (visible and hidden). May be slow or needlessly complex?
Upon row creation, assign an ID to the row that isn't shown to the user and is persisted in the saved file. Would also probably need to have a global counter variable saved (because if a row is deleted we wouldn't want to re-use that ID and we need to know where we left off from).
Assign a GUID to each row? Wouldn't need to store an index counter but more space would be required (although the files are relatively small so I'm not sure how much this matters).
Are there any other or better ways that I'm missing? How is this normally handled?
I'd go with 4 or 5, but with a minor change:
You can keep the JSON as is. Upon importing the JSON, you map each item and assign them an ID or GUID - I'd use ID for simplicity, but it's up to you. Within the execution of your program, this field will be used to the CRUD operations and/or sorting.
When your program is done, map again your data, and save back in the same format you've received (removing the new prop you've added).

ExtJS.Grid editing with lookup table

I'm developing a "simple" CRUD with ExtJS.Grid. This grid will refere to a DB table. I'm using this example as basis.
But I can't figure out how to implement the "Light" column lookup. In the table to be edited, it's an int FK refering to another table, where the text is stored.
I don't need to edit the lookup table. What I need to do is query it (I could provide its data as a static JSON, no need to AJAX query it) so that the main table's FK is replaced by the text.
The editing row must show it as a select/dropdown (as in the example). And when user sends a Create/Update operation, it must send the chose item's ID so I can write it to the table.
There are several possible approaches:
column with combo editor would link to foreign id via dataIndex. This approach is very simple provided that you can load the complete combo store, i.e. it is not too many records. Also, you must ensure that the store is loaded early enough and to provide a column renderer that would display texts, not ids.
if you need a remote store for combo then another approach is better. You deliver from the server both FK (numeric id) and the corresponding text for each grid record, you link combo to the text, not to the id, and you provide edit event listener that updates both id and text when users selects from the combo. This approach is described in details together with the code in Remote Combo in ExtJS Grid Example

Get DHTMLX Grid Cell Type

How do I get that object name circled in red (see image). I've already tried this and it didn't work: https://stackoverflow.com/a/10314492/3112803
Details: I have a DHTMLX grid where cells in a certain column can be a different type per row (either a checkbox or an image). From what I can tell their API gives you a way to SET different types, example: mygrid.setCellExcellType(rowId,colIdx,"img"); but they don't have a function for GETTING the types. http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:api_toc_alpha I need to determine what type the cell is (and I don't want to do it via looking at the innerHTML). Look at the attached image from Chrome console. Those are the objects in the cells. If I can somehow grab what is circled in red then I could determine the type. I don't know how to grab that name.
UPDATE: Still not solved. Another forum on this same issue: http://forum.dhtmlx.com/viewtopic.php?f=2&t=34217&start=0
Uhmmmm, in the API there's a function called getColType(cInd).
mygrid.getColType(8) ---> returns i.e. "price"
GRID API

How can I get the number of rows displayed in a jqGrid?

Maybe this information is out there and my Google-fu is failing me, however I can't seem to find the answer. How can I get the number of rows being currently displayed in a jqGrid?
Every question and answer I've found on this topic tells you how to get either the total number of rows (displayed or not) or the number of rows loaded by an external service. Instead, I'm trying to get how many rows are being displayed in the current page of the jqGrid. One of my jqGrid attributes is rowList:[10,20,30], but I'm not sure how to access which one is selected myself.
All I want is how many rows are being currently dislpayed on each page of the jqGrid. The closest thing I've found so far has been this Q&A, but this displayed how many <tr>s there are and wasn't really what I needed.
$('.ui-pg-selbox').val()
Tested on the latest jqGrid (4.4.1)
Of course, if you have more than jqGrid per page, you can use an wrapper to ensure that it is the one you're looking for.
$('#myjqGridWrapper .ui-pg-selbox').val()
Not sure whether it's the best way, but it gets the job done.
The space means a descendant selector, that is it looks for elements containing the class ui-pg-selbox which are descendant of an wrapper #myjqGridWrapper. That would require having a div or some other wrapper around your table.
UPDATE: Also, if you have the table ID or a reference, you can use a more sturdy way of querying its jqGrid instance's .ui-pg-selbox:
$('#jqgridTableId').closest('.ui-jqgrid').find('.ui-pg-selbox').val()
The following will return you the number of displayed rows on a grid's page:
$('#myjqGridWrapper').getGridParam('reccount');
You shouldn't rely on the view for information. You should pull this information out of the JQGrid model. You can do so by calling the getGridParam method like so:
var rowNum = jqGrid.getGridParam('rowNum');
See here for more information: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options

Categories