SlickGrid deleting a column does not delete its data - slickgrid

I am adding a new column to SlickGrid using of course grid.setColumns(newColumnDef);
I allow the user to then enter values into this new column
If they so choose they can remove this column and add another column which they can select from a dropdown list.
This all works fine, the column gets removed and the grid appears without the removed column. However when I call dataView.getItems() to grab the data from the grid the columns I'vd previously removed are still there. Looks like setColumns with a new column definition and dataView.refresh does not delete the columns data, just the column is removed. I need to remove the columns data when the column is removed... Any suggestions would be most helpful.

Changing the presentation of the data does not change the data itself.

Use deleteItem method of dataview as follows,
dataView.deleteItem(id);\\where id is your unique id
dataView.refresh();`

Related

Set data validation for column including new rows

I have a column in a Google spreadsheet with data validation, that makes a drop down menu available when editing existing rows. Occasionally though contributors create new rows at the bottom of the doc and this validation is lost.
I would like to keep this validatation in the column even in newly created rows (excluding the header row).
I have seen much of this discussion throughout stackoverflow and google help forums, but still cannot find a clear answer.
My hunch is that this would involve Google Apps Acript using an onEdit trigger and then either paint formatting or a combination of the confusing class DataValidationBuilder. (https://developers.google.com/apps-script/reference/spreadsheet/data-validation-builder) but I'm not sure beyond that.
While not necessarily elegant I found the following to work:
create your validation on the entire column
once that's done click the cell(s) that represent the heading, select data / validation, and then click on 'remove validation' on that single cell.
This way any newly inserted rows will inherit the validation set up on the entire column and you don't have to always be reminded that your heading isn't a valid value.
onEdit trigger which uses Range.getDataValidation() and Range.setDataValidation() to copy the rule from an existing row to the new row
While in the data validation dialog screen you can manually enter the range as "Sheet1!A:A" to apply the formula to all of column A.
This also includes new rows added afterwards
I'm not sure if this is a new feature but this worked. Set the validation as list from interval and interval as:
'sheet'!C2:C
This includes all new rows excluding title(first row)

Get original cell data in jqgrid

In my asp.net application, I'm using jqGrid and I am trying to trim the display text of a cell by terminating it with ...
Now, onSelectRow or by click on the message column cell, I want the original long message.
I tried duplicating the same column by giving different index name and kept it hidden. But here I am unable to retrieve cell data by index name.
Any idea here?
Resolved by duplicating message column with different headertext in DataGrid so that name in colModel can be different. Kept this column hidden and retrieving full message from this hidden column.
Any other better solution will be appreciated.

Want to fix some columns

I want to fix some columns so that user cannot drag and drop these columns and cannot reorder these columns also.Is it doable how can i do it.
There is code inside grid.jqueryui.js that uses the jQuery UI Sortable Interaction to enable drag-and-drop columns.
The following selector determines which columns can be dragged-and-dropped:
"items": '>th:not(:has(#jqgh_'+tid+'_cb'+',#jqgh_'+tid+'_rn'+',#jqgh_'+tid+'_subgrid),:hidden)',
So basically the selector will choose any column header that is not hidden and does not satisfy one of the following criteria:
#jqgh_'+tid+'_cb' - A checkbox column (for multi-select)
#jqgh_'+tid+'_rn' - A row number column (for primary key?)
#jqgh_'+tid+'_subgrid - A subgrid column
To satisfy your request, jqGrid would have to be modified to populate the items selector with blacklisted columns. Maybe the blacklisted columns could be flagged using a new colmodel option. This is all do-able, but requires changes to jqGrid itself...

jqgrid delete row only on screen and save the deleted row

I'm using jqgrid with inline editing , when the user gets to the last cell inside a row , when he clickes on "tab" key he will be editing the next row - and if it does not exist a new row will be created.
I want to add a delete row function for the user , but still to have that row data inorder to send it later to the server as a deleted row.
I tried hiding the row , but then when the user "tabs" to the next row - it goes to the hided row - and i want it to go only to the not hided rows.
Is there a way to mark a row as deleted? and then when I generate the xml from the grid rows it will be a part of those rows? or is there a way to delete the row and save it's cells values , and be able to navigate throgh the grids line without going throgh the deleted line?
Any help will be appritiated!
Thank's In Advance.
To fix problem with editing of hidden row you can try to add class "not-editable-row" to the row which you hide.
$("#"+rowid).addClass("not-editable-row").hide();
If it will not help you will have to overwrite the default "TAB" behavior of jqGrid (see the question for implementation details)
Probably more easer way would be to use delRowData which delete a row from the grid without sending any information to the server. If you want to have your custom implementation of the "Delete" button in the navigator (see the example here). Inside of your onClickButton event handler you can save the contain of rows, which will be deleted, to some JavaScript array/object and then delete the row with respect of delRowData. So you can trace all delete operation, save deleted rows and send later all needed informations to the server.

Make only certain columns editable in SlickGrid

I have a grid with multiple columns and I use the first column for a row label. I looked at the example for making the grid editable, but that appears to make the whole grid editable. Is there away to specify a certain column(s) only?
Got it! By not setting the editor property on the column object the column is non-editable.

Resources