Get DHTMLX Grid Cell Type - javascript

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

Related

W2UI Grid selects entire row when clicked, how to select single cell or column for copying?

Running into an issue with the W2UI grid.
Goal: I'd like to be able to select an entire column and copy/paste it to Gsheets. Alternately I'd like to be able to click a single cell and copy it's contents too.
Issue: When clicking it selects the entire row including all irrelevant columns, and copying that includes headers too, meaning it has to be cleaned manually before it can be inserted into a spreadsheet.
The "editable" property allows me to select a single cells contents but even that's not quite what I'm looking for as it required 2 clicks, highlighting text then copying, adding 3-4 button presses to the process.
Can't seem to find the answer on how to fix this in the documentation but I may just be missing something.
Option 1:
You could (temporarily) switch the select type from row (default) to cell.
Just make sure to remove any existing row selection first, otherwise it may look confusing.
Assuming your grid is named grid:
w2ui.grid.selectNone();
w2ui.grid.selectType = 'cell';
w2ui.grid.refresh();
Fiddle: http://jsfiddle.net/yghueLxp/
Option 2:
There's also a new (undocumented) feature to add a copy icon to whole columns - also demonstrated in the linked fiddle, on the first column.
All you have to do is add clipboardCopy: true to the column properties.
For this new feature you'll have to use the dist files of the current github master - it's not available in w2ui 1.5 RC.
By the way, you can make the grid behave similar to an Excel sheet, allowing copy & paste of multiple cells, see: Spreadsheet Like JavaScript Grid
I'd like to be able to [...] paste it to Gsheets
The copied values are TAB separated. This works well when you copy&paste to/from MS Excel. I don't know about Gsheets.

Best way to give conditional formatting to handsontable when data is more than 5k

We have data around 5000 to 10000.
Now in that data, we have to give conditional styling to row, column or some cell.
I try to give conditional formatting, as they have suggested in this link.
But we are facing performance issues. So how to give styling where there is bigger data.
I tried to use hot.getCell() function, but that function is giving null value.
As, you need to detect the limit of data, obviously you need to check this on either, key strokes (worst), other events, getCell().
getCell() works flawlessly if your code is rendering properly.
You can modify cellProperties in cells option function in configuration object. For example you can call function in cells method, that will check properties which you want to add to your configuration. This should work.
The option mentioned above is called cells not cell. Other than that it's true :)

display two columns from a geojson as the property of an object

I am working on a javascript based website project utilizing geojson data. My problem is that I have an object somewhere in the code and of course there are several properties belong to that object.
Let's say that it is something as follows:
pointLayer:{
title:feature.properties.parcelName
}
So, when I run the app, on the basis of this piece of code the "title" which appears on the screen becomes only the Parcel Name. However I would like one more colum from the geojson in a way that both of them will be merged and displayed as an whole. Or another option might be adding just a text other than adding one more column. I wonder if that is something possible to do.
Just to make it clear, I am trying to do something like this. I know that it is completely wrong. I am giving this one below just to show what I am trying to reach.
pointLayer:{
title:feature.properties.parcelName + feature.properties.parcelNumber
}

Slickgrid id column

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.

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