Gridil endal seada EnableCallBacks="false"
Näide selline, et seal nüüd kaks nuppu rea peal
<dxwgv:ASPxGridView ID="ASPxGridViewElements" runat="server" KeyFieldName="CfPers_ExpSkillsId"
Settings-ShowColumnHeaders="false" AutoGenerateColumns="false" SettingsText-ConfirmDelete="Kas soovid kustutada ?"
onhtmldatacellprepared="ASPxGridViewElements_HtmlDataCellPrepared" SettingsBehavior-ConfirmDelete="true"
oncustombuttoncallback="ASPxGridViewElements_CustomButtonCallback"
onrowdeleting="ASPxGridViewElements_RowDeleting" EnableCallBacks="false" >
<Columns>
<dxwgv:GridViewDataColumn VisibleIndex="0" FieldName="CfPers_ExpSkillsId">
<DataItemTemplate>
<dxe:ASPxLabel runat="server" ID="ASPxLabelPeriod" Text=""></dxe:ASPxLabel>
</DataItemTemplate>
</dxwgv:GridViewDataColumn>
<dxwgv:GridViewDataTextColumn FieldName="CfNameEST" VisibleIndex="1">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="CfNameALT" VisibleIndex="2">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewCommandColumn ButtonType="Image" DeleteButton-Visible="true" Name="CommandColumn" VisibleIndex="3">
<CustomButtons>
<dxwgv:GridViewCommandColumnCustomButton Text="Muuda" Image-AlternateText="Muuda" ID="ButtonMuuda" Image-Url="../App_Themes/ETIS/gfx/icons/icon_edit.gif">
</dxwgv:GridViewCommandColumnCustomButton>
</CustomButtons>
<DeleteButton Image-Url="../App_Themes/ETIS/gfx/icons/icon_delete.gif" Image-AlternateText="Kustuta" Text="Kustuta">
</DeleteButton>
</dxwgv:GridViewCommandColumn>
<dxwgv:GridViewDataTextColumn FieldName="StartYear" VisibleIndex="4" Visible="false">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="EndYear" VisibleIndex="5" Visible="false">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="TimestampEST" VisibleIndex="6" Visible="false">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="TimestampALT" VisibleIndex="7" Visible="false">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ExpSkillsIdEST" VisibleIndex="8" Visible="false">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ExpSkillsIdALT" VisibleIndex="9" Visible="false">
</dxwgv:GridViewDataTextColumn>
</Columns>
</dxwgv:ASPxGridView>
"Kustuta" - selle nupu jaoks et tuleks ennem hoiatusaken tuleb SettingsBehavior-ConfirmDelete="true" ja et ilus tekst tuleks siis SettingsText-ConfirmDelete="Kas soovid kustutada ?"
ja kustutamine ise tehakse
protected void ASPxGridViewElements_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
{
this.DeleteCVElement(Convert.ToInt32(e.Values["CfPers_ExpSkillsId"].ToString()));
//see Cancel osa on ASPx DataGridi nõutud värk
e.Cancel = true;
this.ASPxGridViewElements.CancelEdit();
this.FillDataGrid();
}
meetodis, kus kõigepealt kustutab enda tehtud meetodiga, siis keelab Gridi enda kustutamise meetodi ära
e.Cancel = true;
this.ASPxGridViewElements.CancelEdit();
ja täidab Gridi andmetega uuesti
this.FillDataGrid(); // see siin on omalooming
"Muuda" nupp, siin see ennam korralikult tööle ei hakka, kui Gridil endal EnableCallBacks="false" , muidu klikid j aklikid aga ekraanil midagi ei juhtu
protected void ASPxGridViewElements_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e)
{
if (e.ButtonID == "ButtonMuuda")
{
try
{
ASPxGridView grid = sender as ASPxGridView;
string[] copiedFields = new string[] { "CfNameEST", "CfNameALT", "CfPers_ExpSkillsId", "StartYear", "EndYear", "TimestampEST", "TimestampALT", "ExpSkillsIdEST", "ExpSkillsIdALT" };
System.Collections.Hashtable copiedValues = new System.Collections.Hashtable();
foreach (string fieldName in copiedFields)
{
copiedValues[fieldName] = grid.GetRowValues(e.VisibleIndex, fieldName);
}
this.ASPxButtonLisa.Visible = false;
this.ASPxLabelTekstLisa.Text = "Muuda " + this.ASPxLabelTextName.Text.ToLower();
this.PanelElementLisa.Visible = true;
if (this.TekstMemo)
{
this.ASPxMemoEST.Text = copiedValues["CfNameEST"].ToString();
this.ASPxMemoALT.Text = copiedValues["CfNameALT"].ToString();
}
else
{
this.ASPxTextBoxEST.Text = copiedValues["CfNameEST"].ToString();
this.ASPxTextBoxALT.Text = copiedValues["CfNameALT"].ToString();
}
if (this.alguspaevaridanahtav)
{
this.ASPxTextBoxAlgus.Text = copiedValues["StartYear"].ToString();
}
if (this.lopppaevaridanahtav)
{
this.ASPxTextBoxLopp.Text = copiedValues["EndYear"].ToString();
}
}
catch (SystemException ex)
{
this.CustomValidator1.ErrorMessage = ex.Message;
this.CustomValidator1.IsValid = false;
}
}
}
Blogged with the Flock Browser