I am using devexpress for windows application. I am having a devxgrid which populates the data and at the last column, I have a hyperlink button named cancel. When I click the cancel button it will do some functionalities that is working great. After that the corresponding cancel button should be disabled. How to make it disabled? Any help is greatly appreciated.
There are two ways to implement this task:
Create two ButtonEdit repository items. One with the enabled button and another with the disabled button. Then handle the GridView.CustomRowCellEdit event and pass the necessary repository item to the e.RepositoryItem parameter according to a specific condition. Please see the Assigning Editors to Individual Cells help topic for additional information.
If the button editor has several buttons and their Enabled state must be changed dynamically, you can implement this functionality by handling the GridView.CustomDrawCell event as shown in the following DevExpress Forum thread:
How to display disabled buttons for particular cells within a ButtonEdit column
.
But you should follow the first approach, In case of hyperlinkEdit., for your implementation logic add a custom column with bool values, that will give you condition that whether you will show enabled or disabled hyperlinkEdit repository edit.
If you just want to set this readonly then you do in following way:
you can make the editor read only by handling CustomRowCellEdit:
private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
if(code goes here)
e.RepositoryItem.ReadOnly = true;
}
you can also prevent the editor from being show by handling ShowingEditor:
private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
{
if (code goes here)
e.Cancel = true;
}
Hope this help you to solve your task..
Related
I have a custom DateTimePicker control that prepared for Persian calendar. Is there any way to add it to the DevExpress GridControl column?
Please help me.
From: Creating a custom (RepositoryItem) ImageComboBox
If you wish to use your custom control in GridControl, it is necessary
to create an editor and its RepositoryItem descendants.
Please refer to the Custom Editors and How to register a custom
editor for use in the XtraGrid articles for complete information
on how to create custom controls. You can find some custom editor
descendants in our examples: editor descendants.
The RepositoryItem class contains editor settings and is used as
a template for cells in the grid. In the display mode, GridControl
only draws cells content via RepositoryItem's methods. In the edit
mode, GridControl creates a corresponding editor via the
RepositoryItem.CreateEditor method. Thus, if you wish to add items to
the editor used in the grid on its initialization, implement this at
the RepositoryItem level.
You can set an editor for the auto filter row if you handle GridView.CustomRowCellEdit event with following code
RepositoryItemDateEdit rd = new RepositoryItemDateEdit();
void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) {
GridView view = sender as GridView;
if(e.Column.FieldName == "DOB" && view.IsFilterRow(e.RowHandle)) {
e.RepositoryItem = rd;
}
}
Review the Assigning Editors to Columns and Card Fields help article to learn how to assign a specific editor to a particular GridView's column.
I hope you will find this information useful.
I have a sub grid on a new entity called Issues, the sub grid is for another new entity called Cost Detail.
I have them both loaded into my solution called Issue, and have opened issue in the ribbon workbench.
What I want to do is when you are on the Issue form and can see the sub-grid I want to be able to hide the + button which is displayed. However when I have hidden this button in the ribbon workbench it also hides the add new button in the 'Associated View' therefore no records can be added.
How do I do it so that only the + button on the sub grid is hidden and not the other view?
EDIT:
In order to hide the add button, you either need to take away create privileges to the role that the user is in or you could do a hack(unsupported) like this:
function hideAddButton(){
var addButton = $('#NameOfGrid_addImageButton');
if(addButton.size())
addButton.hide();
else
setTimeout(hideAddButton, 1000);//checks every second to see if the button exists yet
}
and call the hideAddButton function on form load
There is one answer that I found. If you have a field that unique for that entity, then you can do it with a simple javascript code.
Here is steps that you must follow in ribbon workbench:
Right click the button and customise button.
Add an enable rule, in Steps section add an Custom Javascript Rule, that contains your library and function name, please make sure that default is true.
This must be in your javascirpt library :
function hideAddNew(){
if(Xrm.Page.getAttribute("yourField")){
return false;
}
else {
return true;
}
}
Add a command that contains the enable rule we created.
Add the command to button.
That's it. I test it, it is working.
I am adding a dynamic grid to a view port on click of a button the data in the store is from an ajax proxy , I am using the same code as in http://examples.ext.net/#/GridPanel/Saving_Variations/HttpHandler/
but the difference is I am adding it in behind code .
First problem is all the icon are not showing it is saying that it is cannot be found.
Second problem is that I am getting the headers and the buttons and they are functioning properly but there is no data displayed in the grid ...
Please help I have tried every thing I know here .
Firstly the icons may need to be registered in order for them to be rendered. Use the following code. This is especially true when loading icons dynamically.
protected void Page_Load(object sender, EventArgs e)
{
if(!X.IsAjaxRequest)
{
this.resourceManager.RegisterIcon(Icon.Lorry);
}
}
Secondly, if you are seeing blank rows in the grid it would suggest the data is being loaded but that you have a case mis-match between your ModelField and Column DataIndex value(s). DataIndex values are CASE SENSITIVE.
I hope this helps.
Thanks,
Gav
It is known that the ListView control can't display both an EmptyDataTemplate and a InsertItemTemplate at the same time.
For my design style I need to be able to show both. I want to be able to show that no data exist and at the same time show a form to add new data.
I've already implemented various solutions, such as putting a PlaceHolder in my LayoutTemplate and then manually showing or hiding this PlaceHolder in the code-behind, depending on if there is data or not.
However, I would like a control that has this built-in capability in order to keep my code-behind light.
I believe there are only two ways to achieve what I want:
First way (preferred) is to write that custom control myself. I was thinking of deriving from ListView and overriding the function responsible for disabling the EmptyDataTemplate, but I have no experience with custom controls. And I'm not even sure it will work in the end.
Second way is to use a custom control found or purchased somewhere. I have not been able to find such control that has the same base capabilities as the ListView.
Has anybody any idea how to solve #1 and maybe #2?
Thank you.
Here is what I ended up doing:
public class MyListView : ListView
{
protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding)
{
int itemCount = base.CreateChildControls(dataSource, dataBinding);
if (this.InsertItemPosition != InsertItemPosition.None && itemCount == 0)
{
CreateEmptyDataItem();
}
return itemCount;
}
}
Works great!
I would go for your option 1: Create a custom control
Because you haven't specified a programming language I made one in VB.NET:
Public Class CustomListView
Inherits ListView
Public Sub CheckEmptyData() Handles Me.PreRender
If Me.Items.Count = 0 Then
Dim label As New Label
label.Text = "No data found <br/>"
Me.Controls.AddAt(0, label)
End If
End Sub
End Class
Just tested it and works perfectly, it can just replace an existing ListView.
As you can see it checks if there is any data and if not it inserts a label with the text "No data found". I haven't found an easy way to use the EmptyDataTemplate for this, that would be a better option but this might already work for you.
Another option is to hide the InsertItem (InsertItemPosition.None) if there is no data, and add a Button "Insert" to the EmptyDataTemplate that enables the InsertItemTemplate and therefore hides the EmptyDataTemplate.
I don't understand much of your requirement without a screen shot of what you are actually trying to achieve. Anyway, you may be able to achieve this interface with a combination of ListView+FormView or ListView+ a User Control. If you can provide any more info I may help further.
Im implementing custrom delete by adding to my ASPxGridView GridViewColumnCustomButton.
Then on my GridView I handle ClientSideEvent
<ClientSideEvents CustomButtonClick="function(s, e) { customButton_OnClick(s, e); }" />
JS:
function customButton_OnClick(s, e) {
if (e.buttonID == "customButtonId") {
e.processOnServer = confirm("Really want to delete?");
}
}
Ive also added to my grid:
OnCustomButtonCallback="GvMyGridViews_OnCustomCallback"
now on the server side I user linq to delete specified row and then submit changes to my DataContext and then DataBind() on my grid.
Problem is that sometimes standard ASPxGridView loading panel is shown for about 1 second ant then my row dissapears so it behaves properly but sometimes loading panel stops mooving. and I need to move mouse over my grid or click button so that my Grid is updated(row dissapears).
Have You got any Idea where the problem is ?
Thanks for help
It it hard to answer your question. Please try to determine if the row was actually deleted from the DB when you call the grid's DataBind method. Also, I suspect that the ASPxGridView is bound to a LinqDataSource object. If so, I suggest that you log which data it returns and check if a row deleted is in the list. It is possible since this component can cache data and return a non valid recordset. To determine which data is returned by the LinqDataSource, you may use the code from
http://forums.asp.net/p/1583916/3998100.aspx
Make sure that after you delete the record at the end of your custombuttoncallback handler that you SET THE DATASOURCE then rebind the grid. If you just call DataBind() without setting the datasource it will not work properly. Ie.
aspxGrid.DataSource = updatedDataSourceAfterTheDelete;
aspxGrid.DataBind();