Flexigrid - how to turn off row selection - flexigrid

Is it possible to turn off the row selection feature on Flexigrid?
It's somewhat annoying when you haven't implemented anything that makes use of the selection.

Unfortunately Mr Flibble's accepted answer does not stop all selection capability, it merely restricts it to one row.
To disable it completely, add a new property to the $.extend block (around line 20)
// apply default properties
p = $.extend({
<SNIP>
onSubmit: false, // using a custom populate function
disableSelect: true
Then in the .click section of the row (around line 754) add a check for the property
$(this)
.click(
function (e)
{
var obj = (e.target || e.srcElement); if (obj.href || obj.type) return true;
if (p.disableSelect) return true;
$(this).toggleClass('trSelected');
if (p.singleSelect) $(this).siblings().removeClass('trSelected');
}
)

Turns out you need to change the singleSelect property to true.
singleSelect: true

I know this thread is a bit old but I came upon it looking for the same thing. The singleSelect didn't work for me as I didn't want to be able to select any row. I found that I could remove any row selection with a single line of code:
$('.grid tr').unbind('click');
This a course removes all bindings on the table row so if you needed the binding you won't have it unless you rebind later but I needed to remove any and all row selection on my table. I didn't need to touch the flexigrid code to do so which I liked a bit more than previous answers.

Related

how to disable add/edit/delete toolbar button in row selection in Acumatica PXGrid?

how to enabled/disabled add/edit/delete toolbar button in row selection in Acumatica PXGrid?
I saw below post but i don't want to use this because i am using Acumatica existing Form view, i don't want to affect their form if our custom funcationality not available. Is there a way to use row selection event to enable/disabled toolbar button or any other way to disabled buttons?
Action upon selecting a line in a grid
You should be able to override the RowSelected event handler (as you asked) to modify access to AllowUpdate, AllowInsert, and AllowDelete on the cache associated to that grid.
If the cache is already being set and you want to disable it, you can simply set the related cache.Allow--- to false based on your condition.
if(myAddCondition == true) MyViewName.AllowInsert = false;
if(myUpdateCondition == true) MyViewName.AllowUpdate = false;
if(myDeleteCondition == true) MyViewName.AllowDelete = false;
Remember that this will not inherently enable it again for the next row, so if you don't have code that already sets enable/disable, you should use the syntax:
MyViewName.AllowInsert = (myAddCondition == true);
MyViewName.AllowUpdate = (myUpdateCondition == true);
MyViewName.AllowDelete = (myDeleteCondition == true);
Be mindful that the base graph that you are modifying may have disabled the action on the cache already, so you want to be careful that you are not enabling it again unless you truly intend to do so.
Under certain conditions, you may need to refer specifically to the Cache of the view...
MyViewName.Cache.Allow[Insert/Update/Delete]

Gridcontrol edit/update mandatory fields different colour

I'm just wondering how can I change background colour of mandatory fields while adding new row.
So for example name and surname would be red (mandatory) and phone would be default white.
Thank you
Patryk
The best way to do this is through the grid's designer -- in most cases you don't need to write any code to accomplish this.
If you go to the Grid View designer, select the menu item "Appearance" and "Format Rules:"
From here, you can add a format condition by clicking the plus icon:
Under "Column," pick the column you want the format condition to apply to.
Under "Rule," pick an appropriate rule -- based on what you described, you probably want "Format Based on a Value," FormatConditionRuleValue.
On the "Rule" tab of this same dialog, you can set your "Value1" and "Condition" properties accordingly, for example Value1 = 15, Condition = "equals."
The "Appearance" property will let you determine how to format the cell based on these conditions.
The beauty of this approach is it's all designer-based code, and it's very easy to customize. The logic behind the formatting is also very transparent. The format conditions have been expanded to let you evaluate expressions as well, meaning you can create your own formulas using other column values and functions.
If all else fails, you can use the RowCellStyle event, but my first attempt would always to be to use the designer tools.
You can use an event gvView_CustomDrawCell and set background color only if the line is in state that you need (Added, Detached ...)
private void gvView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column != null && (e.Column.Name == bgcName.Name || e.Column.Name == bgcSureName.Name))
{
DataRow focusedRow = gvView.GetDataRow(e.RowHandle);
if (focusedRow != null)
{
if (focusedRow.RowState == DataRowState.Added)
{
e.Appearance.BackColor = Color.FromArgb(80, 10, 30, 200);
}
}
}
}
asd

Clearing input textbox using FuncUnit

I am writing FuncUnit for my application. I am browsing the application in Google Chrome. I have a textbox which is initially hidden. I need to make it visible and then clear the text already present in that textbox. I have the following code which makes the box visible but fails to clear the text in it.
S('#search').visible().clearText();
Can anyone tell what is wrong here?
Try to clear the textbox by typing - Ctrl+A and Delete.
var input = S('input.my-input');
input.type('[ctrl]a[ctrl-up][delete]', function() {
// Continue in test case after the text has been removed
});
Your statement is not accurate. visible() does not turn things visible. It is a wait function which waits for the source element to become visible before proceeding to the next action.
koalix's key sequence works. With the type() command you might need to first click into the text input before clearing it.
Try:
S('#search').visible().click().type('[ctrl]a[ctrl-up][delete]');
You could also try empty quotes <" ">
var input = S('input.my-input');
input.type('', function() {
// remove existing text
});
I don't know if you're still waiting for an answer.
I think you're not using visible() in the correct way.
In FuncUnit (see docs here), among other things, you can distinguish between "actions" and "waits". visible() is a wait, and should be used to wait for an element to become visible, like this:
S('#el').visible( function() {
// do something when element with id="el" becomes visible
});

Dojo EnhancedGrid and programmatic selection

Here's my problem: in my application I have a Dojo EnhancedGrid, backed up by an ItemFileReadStore. The page flow looks like this:
The user selects a value from a selection list.
The item from the list is posted on a server and then the grid is updated with data from the server (don't ask why, this is how it's supposed to work)
The new item is highlighted in the grid.
Now, the first two steps work like a charm; however, the third step gave me some headaches. After the data is successfully POSTed to the server (via dojo.xhrPost() ) the following code runs:
myGrid.store.close();
myGrid._refresh();
myGrid.store.fetch({
onComplete : function(items) {
for ( var i = 0; i < items.length; i++) {
if (items[i].documentType[0].id == documentTypeId) {
var newItemIndex = myGrid.getItemIndex(items[i]);
exportMappingGrid.selection.deselectAll();
exportMappingGrid.selection.addToSelection(newItemIndex);
}
}
}
});
Now, the selection of the grid is updated (i.e. the selection object has a selectedIndex > 0), but visually there's no response, unless I hover the mouse over the "selected" row. If I remove the .deselectAll() line (which I suspected as the culprit) then I sometimes end up with two items selected at once, although the grid selectionMode attribute is set to single.
Any thoughts on this one?
Thanks a lot.
You need to use setSelected(), like so
exportMappingGrid.selection.setSelected(newItemIndex, true);
The second parameter is true to select the row, false to unselect it.
This is what works for me:
grid.selection.clear();
grid.selection.addToSelection(newItemIndex);
grid.selection.getFirstSelected();
Jon

setSelected() in dojo DataGrid leaves previous selection active even for grid with selectionMode="single"

I have a dojox.grid.DataGrid where I want to select a row programmatically. I'm using setSelected() to do so and it works the first time. However, calling it a second time for a different row leaves the previous row highlighted. Also, if I try to reselect a row that was previously selected, the onSelected event does not fire. But if I actually click in the grid, it clears things up: rows that were highlighted in the grid before get unhighlighted and unselected.
The code looks like so:
if (grid.rowCount > 0 && idx < grid.rowCount)
{
grid.selection.setSelected(idx, true);
grid.render();
}
It is as if I had multi-select enabled, but I have declared the grid as selectionMode="single".
<table dojoType="dojox.grid.DataGrid"
id="hotTablesForAppDg"
autoWidth="true" autoHeight="true" selectionMode="single"
onSelected="autonomics.Clusters.loadTableDetails(this)">
Is there something else I need to call to clear the previous selection?
Problem solved. You need to call setSelected(..., false) on the currently selected index:
if (grid.rowCount > 0 && idx < grid.rowCount)
{
if (grid.selection.selectedIndex >= 0)
{
// If there is a currently selected row, deselect it now
grid.selection.setSelected(grid.selection.selectedIndex, false);
}
grid.selection.setSelected(idx, true);
grid.render();
}
I had the same issue, of grid having the previous selection active.
Following line of code
grid.selection.clear();
before calling the render(), resolved the issue. Hope this helps.