jqGrid cell formatter property - jqgrid

Is there a way to update formatter on a single cell of a column dynamically. I'm able to change the formatter for the entire column using
$(jQuery('#grid').jqGrid('setColProp', 'colName', {formatter: ''})).trigger('reloadGrid')
However when I use code below the grid refreshes but with no changes.
$(jQuery('#grid').jqGrid('setCell', j, 'colName', '','',{formatter: ''})).trigger('reloadGrid')

No, the formatter is for the whole column, not a single cell. If you need this level of granularity, you will need to use a custom formatter function with logic that can somehow detect that you are in that particular cell - such as by using the row object to get the row ID.

Related

How to set cell color if value is present in Angular slickgrid

I'm using Angular slickgrid and I want to change the cell color if the value is present in that cell.
Note: I want the color only for the cell not the whole row.
Is there any best way to iterate over all the cells and set the color or any equivalent solution?
I have a requirement to show the different cell colors depending on the data. Red color if the data is coming from the server and not changed (not dirty). If the data is edited or added new row (dirty), the cell color would be blue. I have updated the question.
function renderCellWithColor(cellNode, row, dataContext, colDef) {
if (dataContext[colDef.field] != ""){
$(cellNode).addClass("requiredClass"))
}
}
I'm using this function using enableAsyncPostRender. This does not work if I edit or add new row.
Use the option cssClass on the column definition or use a Custom Formatter returning an object following the FormatterResultObject, see Wikis Custom Formatter - FormatterResultObject - Wiki and sample - Wiki, the FormatterResultObject has the advantage of applying the CSS class to the cell container via the property addClasses and using the formatter object is the only way to get access to the cell container.

Adding a drop-down menu (data validation) after each row of a query result in Google Sheet

First, here is the link to my sheet:
https://docs.google.com/spreadsheets/d/1067N1SAIwpGkMRBZiUv4JW8yDNkozuGt7Fwh6GW-qvE/edit#gid=1742559851
If you look at the tab called "Selection", I have two columns called "Select". All the data in these tables is collected by a query function, except column "Select". In that column, I need to add Data Validation (a simple Yes or No). I want the Data Validation to be automatically added when a new row is created but the query function instead of having to add or remove it manually every time I make some changed. Data collected by the query function is using the two variables on top of the sheet (minimum rating and global buff).
Just to show the step to apply data validation to your whole column, see the following image. Under Cell Range, the image shows Selection!D5:D99, but this is actually set to Selection!D5:D999, it just is truncated due to the size of the text box.
Let us know if this is what you were looking for, or if I've misunderstood your issue.

jqGrid get row element within formatter

I created a custom formatter for column in jqGrid. Is it possible to modify the parent TR of that cell? As I can see, the formatter executed before the TR with data added to the DOM so it seems like i can't get the row element by rowID.
I want to change style / CssClass of the TR based on rowObject that I receive in formatter.
You should take a look at rowattr callback (it is available since jqGrid 4.3.2) which allows to modify the row attributes during rendering. The more detailed description is available in following pull request:
Implementation of rowattr callback

What's the best way to control a NSTableView's selection using checkboxes?

For some user interfaces it makes sense to have explicit checkboxes to allow users to select the items in a table. What's the best way to accomplish this using cocoa? In other words, how can I link the state of a checkbox in each row to whether or not the row is currently selected?
Tony,
if I get you correctly, you want to add a leading column to your NSTableView so you can select the corresponding column(s), separate from the usual selection of the tableView.
What is your datasource of the table view? A core data stuff or an array/dictionary? if you do not want to modify your data model, you could set up a distinct array (mutable), to keep track of the selection. bind it to the checkbox column (you would want to add as first column) and keep the array in sync with the number of items in the general datasource for the table that displays your valuable data.
You could also enhance your data model with a column "selected", make it BOOL and bind it to the checkboxes. This would also allow you to easily save the last selection to you database or file, whatever you are using.
Can you update your question with some more information on your data model?
sya - living.

jqgrid add new row - pre-filled

I use two grids at one PHP page.
Is there any way to get data from the first grid (i.e. after click row) and pre-fill it into the add new row form in the second grid?
thank you for any suggestion Petr
I am not sure that I correct understand what you mean under the "pre-filling". But how I understand you question you can do following:
With respect of onSelectRow event which you define on the first grid you will receive the id of selected row as the parameter. Inside of the onSelectRow event handle you can call getRowData to get full information about the data of selected row. Then using addRowData for example you can add new row in the second grid.

Resources