Трябва да обновя DevExpress GridView във функцията за успех на ajax след операция. Използвам метод gridName.Refresh()
, но javascript извежда грешка „udefined не е функция“. Но когато пиша този метод в прозореца на Google Chrome Console, той работи добре. Какъв е проблемът? Освен това моите javascript кодове са в различния JavaScript файл, а не сред html кодовете.
Това са моите jquery ajax кодове в отделения javascript файл
function sendToMethod(url) {
$.ajax({
type: 'GET',
url: url,
contentType: 'application/html; charset=utf-8',
datatype: 'html'
})
.success(function (result) {
onCloseClick();
gv_locations.UnselectRows();//gv_locations is not defined
gv_locations.Refresh();//there is the same error here too
})
.error(function (result) {
});
}
Това е моят файл GridViewPartial.cshtml
@Html.DevExpress().GridView(g =>
{
g.Name = "gv_locations";
g.KeyFieldName = "PublicIP";
g.SettingsPager.PageSize = 21;
g.Width = System.Web.UI.WebControls.Unit.Percentage(100);
g.ClientSideEvents.SelectionChanged = "onGridSelectionChanged";
g.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
g.CommandColumn.Visible = true;
g.Settings.ShowGroupPanel = true;
g.CommandColumn.ShowEditButton = true;
g.CommandColumn.ShowDeleteButton = true;
g.CommandColumn.ShowSelectCheckbox = true;
g.SettingsBehavior.AllowFocusedRow = true;
g.CallbackRouteValues = new { Controller = "Location", Action = "LocationGridViewPartial", id = ViewBag.Type };
g.SettingsEditing.UpdateRowRouteValues = new { Controller = "Location", Action = "LocationGridViewInlineUpdate" };
g.SettingsEditing.DeleteRowRouteValues = new { Controller = "Location", Action = "LocationGridViewInlineDelete" };
g.Columns.Add(column =>
{
column.Caption = "Client";
column.FieldName = "ClientID";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add(column =>
{
column.Caption = "IP";
column.FieldName = "PublicIP";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add("PublicIPName", "Lokasyon Adı");
g.Columns.Add(column =>
{
column.Caption = "Konum Tipi";
column.FieldName = "SelectedLocationTypeID";
column.ColumnType = MVCxGridViewColumnType.ComboBox;
var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
comboBoxProperties.DataSource = AtomicAdminPanel.Models.External.Location.LocationDataProvider.GetLocationTypes();
comboBoxProperties.TextField = "SelectedLocationTypeName";
comboBoxProperties.ValueField = "SelectedLocationTypeID";
});
g.Columns.Add(column =>
{
column.Caption = "Oluşturan";
column.FieldName = "CreatedUser";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add(column =>
{
column.Caption = "Oluşturma Tarihi";
column.FieldName = "CreatedDateTime";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add(column =>
{
column.Caption = "Değiştiren";
column.FieldName = "ChangedUser";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add(column =>
{
column.Caption = "Değiştime Tarihi";
column.FieldName = "ChangedDateTime";
column.EditFormSettings.Visible = DevExpress.Utils.DefaultBoolean.False;
});
g.Columns.Add("IsActive", "Aktif", MVCxGridViewColumnType.CheckBox);
MVCxGridViewColumn col_listType = new MVCxGridViewColumn("LocationListType");
col_listType.Visible = false;
if (ViewBag.Id == "Online")
{
MVCxGridViewColumn col_online = new MVCxGridViewColumn("IsOnline", "Çevrimiçi", MVCxGridViewColumnType.Image);
col_online.SetDataItemTemplateContent(c =>
{
ViewContext.Writer.Write("<img src='../../Content/Image/statusOnline.png'/>");
});
g.Columns.Add(col_online);
}
}).Bind(Model).GetHtml()
gv_locations
не е дефиниран. Javascript файлът на същата страница ли е като GridView? - person Zabavsky   schedule 16.10.2014gv_locations
GridView? - person Zabavsky   schedule 16.10.2014