How to hide or disable the "Add Row" right to the IG when the first row is added oracle apex - oracle11g

I am trying to hide or disable the "Add Row" button right to the IG (Intractive Grid) when the first row is added in Grid.
Only one record should be available in the IG, so once the first is inserted automatically the "Add Row" Button should be hidden or disabled.
I have tried in Js but it’s hiding the button once the page loads.
function(config) {
var i, toolbarData = apex.jQuery.apex.interactiveGrid.copyDefaultToolbar(),
toolbarGroup = toolbarData.toolbarFind("actions3");
// find and remove the add_row button
for (i = 0; i < toolbarGroup.controls.length; i++ ) {
if ( toolbarGroup.controls[i].action === "selection-add-row" ) //for save and edit it is working
{
toolbarGroup.controls.splice(i,4);
break;
}
}
config.toolbarData = toolbarData;
return config;
}

Looks like a vary complicated procedure for a simple task
possible solutions:
If all you need is adding one row - use a form instead of IG
Initiate the region with one empty line, and remove the "Add row" button all in all
Use a dynamic action which is triggered by the Add row button that disables the same button

Related

C# winforms DGV Add a button to a datagrid with variable text

I know how to add a button to a datagridview. What I am having a problem with is changing the text displayed based on whether a associated record exists in another table. I would like to change the text on the button to "View SR" or "Add SR" depending on if a service request exists for the record. if it even possible, how I would go about this ?
You just need to capture the exact cell and cast it in a Grid View Button Cell to adjust the value displayed. Following is a tried solution:
if (SomeTrueValue)
{
((DataGridViewButtonCell)dataGridView1.Rows[0].Cells[0]).Value = "Hello";
}
else
{
((DataGridViewButtonCell)dataGridView1.Rows[0].Cells[0]).Value = "World";
}

How to catch onchange event of radio button that is present in every row of single table in spark ui toolkit

Iam using spark ui table and I have radio button group (Yes and No)and teaxtarea in each row.I have multipe rows.
My requirement is that if click on Yes ,then the textarea should be hidden only in that row.I wrote below code in load
var table = page.ui.get('/tablecv1/Table1');
var radiobtn = table.ui.getSibling('/tablecv1/Table1/Radio_Button_Group1');
radiobtn._instance.input.onchange = function(event){
if(radiobtn.getData() == "yes"){
radiobtn.ui.getSibling("Text_Area1").setVisible(true)
}
else{
radiobtn.ui.getSibling("Text_Area1").setVisible(false,true)
}
}
As of the now the code is working only for the first row.But for the secomnd row,on change of button it is not even going inside that function,the reason may be the control name is same for all.How can I handle this case where I should be able to click radio btn in any row and specific textarea should be hidden
You could pass the target radio button to the inline function. That would be like this:
this.setAreaVisibility = function(radiobtn) {
radiobtn._instance.input.onchange = function(event){
if(radiobtn.getData() == "yes"){
radiobtn.ui.getSibling("Text_Area1").setVisible(true)
}
else{
radiobtn.ui.getSibling("Text_Area1").setVisible(false,true)
}
}
}
Then on "On Change" event of the radio button element you should call this function like this:
me.ui.invoke("setAreaVisibility", me);

Disabling a row in a DOJO / Gridx grid

I have a grid I created in Gridx which lists a bunch of users. Upon clicking a ROW in the grid (any part of that row), a dialog pops up and shows additional information about that user and actions that can be done for that user (disable user, ignore user, etc.) - when one of these options is selected from the pop up, I want to DISABLE that row. The logic for getting the row, etc. I can take care of, but I can't figure out how to make a grid row actually "appear" disabled and how to make that row no longer clickable.
Is there a simple way to do this? If you aren't familiar with gridx, solutions that apply to EnhancedGrids or other Dojo grids are also appreciated.
Alright now that I have a little more information here is a solution:
Keep a list of all the rows you have disabled so far either inside the Grid widget or in its parent code. Then on the onRowClick listener I would write code like this:
on(grid, "onRowClick", function(e) {
if(disabledRows[rowIndex]) {
return;
}
// Do whatever pop up stuff you want and after
// a user selects the value, you can "disable"
// your row afterwards by adding it to the disabled
// list so that it can no longer be clicked on.
var rowIndex = e.rowIndex;
disabledRows[rowIndex] = true;
// This is just some random class I made up but
// you can use css to stylize the row however you want
var rowNode = e.rowNode;
domClass.add(rowNode, "disabled");
});
Note that domClass is what I named "dojo/dom-class". Hope this helps!
This is perhaps not exactly what you are seaching for:
If you want to hide one or more rows by your own filterfunction you could just add to these rows in the DOM your own class for nodisplay. Here I show you a function for display only those rows which have in a choiceable field/column a value inside your filterlist.
function hideRowFilter(gridId, fieldName, filterList)
{
var store = gridId.store;
var rowId;
store.query(function(object){
rowId = gridId.row(object.id,true).node();
if (filterList.indexOf(object[fieldName]) == -1)
domClass.add(rowId, "noDisplay"); // anzeigen
else
domClass.remove(rowId, "noDisplay"); // verstecken
});
}
CSS:
.noDisplay { display: none; }
So I can for example display only the entries with a myState of 3 or 4 with this call:
hideRowFilter(gridId, 'myState', [3, 4]);
Note that domClass is what I named "dojo/dom-class"

dojo enhanced datagrid loses focus after edit

I have an enhanced datagrid that uses a jsonreststore.
I have set the editable cell to auto-save. To do this, I added a onApplyCellEdit property. after successful save (by pressing enter key) the server responds with the new data and my datagrid is updated. however, the focus on the cell just edited loses focus. As a result I cannot use the arrow key to navigate to the next cell, forcing me to use the mouse. Is there any way to regain focus so that I can use the keyboard to navigate after editing?
I have done following code to kind of regain the focus using setTimeout but I think it is not a good solution because if it takes too long for the server to respond the cell will regain focus first and when the response comes in and cell is updated, the cell will lose focus:
var accounts = new EnhancedGrid({
structure: account_layout,
selectionMode: "single",
canSort: function(){
return false
},
onApplyCellEdit: function(inValue,inRowIndex,inFieldIndex){
if(this.store){
this.store.save();
window.setTimeout(function(){
var cells = accounts.layout.cells;
var fieldLocation;
for(var i = 0; i < cells.length; i++){
if(inFieldIndex === cells[i].field){
fieldLocation = i;
break;
}
}
accounts.focus.setFocusCell(cells[fieldLocation],inRowIndex);
},500);
}
}
});
I also tried:
this.store.save().then(function(){ ...});
But it's not working.
EDIT
To clarify question, I added sentence after first sentence of 2nd paragraph.

Add new row when previous "new row" is saved in Kendo Grid

I have created a kendo.data.dataSource without transport (only data with model and fields) with success, and I am able to bind it to the KendoUI Grid on my page.
After loading, the grid is empty. I do calling the net line to add a empty data item in the grid so the user can enter data directly in the grid (inline mode).
$("#divid").data("kendoGrid").addRow();
This all works.
But after the user finished the input and hit the OK/Save button, I like to add a new empty row immediatly, below the previous added row. I try this during the grid function Save:
save: function(e) {
$("#divid").data("kendoGrid").addRow();
}
But the previous row with inserted data disappear and a new empty dataitem isn't added.
Also trying this same way during the datasource event 'change', but with the same behaviour.
My question is, what I doing wrong or what is the best way to add a new empty row to the Kendo Grid when user hits the OK/save button of a current inine editing row.
If you want to save multiple record at a time, you can go for batch editing. You can bind a keypress event to create new row as well. Try this:
$(document.body).keypress(function (e) {
if (e.keyCode == 13) {
var grid = $("#grid").data("kendoGrid");
grid.addRow();
}
});
13 is the value for enter key.

Resources