In IE10 Slickgrid tabbing breaks - internet-explorer-10

Hi I have a slickgrid table that works perfectly in IE8, in IE10 the tabbing breaks.
On the page there is a form that is used as a filter to change what Slick Grid displays. It has a number of text boxes.
If I click into an editable cell and enter a value and then press the tab key. The next column is highlighted as expected but the cursor jumps up to the first text box of the form.
I have updated Slick Grid to the latest version
My columns are defined like this
var columns = [
{ id: 'ParameterOrder', name: 'Order', field: 'ParameterOrder', width: 50 },
{ id: 'CanEnableManualChange', name: 'Enable Manual Change', field: 'CanEnableManualChange', cssClass: 'center', formatter: Slick.Formatters.Checkbox, editor: Slick.Editors.Checkbox, width: 100 },
{ id: 'Name', name: 'Parameter Name', field: 'Name', editor: Slick.Editors.Text, width: 185},
{ id: 'ParameterType', name: 'Parameter Type', field: 'ParameterType', editor: Slick.Editors.Text, width: 185},
{ id: 'LowSpecLimit', name: 'Low Spec Limit', field: 'LowSpecLimit', editable: isEipEditable, focusable:true , editor: Slick.Editors.DecimalEditor, width: 115, valueChangedEvent: trackChangesFunction },
{ id: 'LowControlLimit', name: 'Low Control Limit', field: 'LowControlLimit', editable: isEipEditable, focusable:true, editor: Slick.Editors.DecimalEditor, width: 115, valueChangedEvent: trackChangesFunction },
{ id: 'NominalValue', name: 'Nominal Value', field: 'NominalValue', editable: isEipEditable, editor: Slick.Editors.DecimalEditor, width: 115, valueChangedEvent: trackChangesFunction },
{ id: 'HighControlLimit', name: 'High Control Limit', field: 'HighControlLimit', editable: isEipEditable, editor: Slick.Editors.DecimalEditor, width: 115, valueChangedEvent: trackChangesFunction },
{ id: 'HighSpecLimit', name: 'High Spec Limit', field: 'HighSpecLimit', editable: isEipEditable, editor: Slick.Editors.DecimalEditor, width: 115, valueChangedEvent: trackChangesFunction },
{ id: 'ParameterCategoryId', name: 'Parameter Category', field: 'ParameterCategoryId', options: Slick.OptionArray.MakeFromHtmlSelectList($("#DefineParameter_ParameterCategoryId")), formatter: Slick.Formatters.SelectList, editor: Slick.Editors.SelectCellEditor, width: 115 }
];
EDIT:
This is an extension on slickGrid I found in the project I'm working on
$.extend(true, window, {
mySlick: {
getGrid: function (container, data, columns, options) {
var editOptions = mySlick.refreshEditOption(columns, options.editable);
options.actualGridEdit = options.editable;
options.editable = editOptions.isGridEditable;
return new Slick.Grid(container, data, editOptions.columns, options);
},
refreshEditOption: function (columns, isGridEditable) {
var editableColumns = _.filter(columns, function (item) { return item.editable != null && item.editable; });
var nonEditableColumns = _.filter(columns, function (item) { return (item.editable == null || !item.editable) && !isGridEditable; });
if (editableColumns.length > 0 && !isGridEditable) {
// make the grid editable
isGridEditable = true;
// sets non editable columns to readonly by removing Editor property
_.each(columns, function (item) {
if (item.editable == null || !item.editable) {
delete item.editor;
}
});
}
if (nonEditableColumns.length > 0) {
// sets non editable columns to readonly by removing Editor property
_.each(columns, function (item) {
if (item.editable == null || !item.editable) {
delete item.editor;
}
});
}
return { columns: columns, isGridEditable: isGridEditable };
}
}
});
This is called
var data = JSON.parse($('#DefineParameter_ParametersObject').val() || null) || [];
var options = {
editable: isGridEditable,
enableCellNavigation: true,
autoEdit: true,
enableColumnReorder: false,
orderField: 'ParameterOrder'
};
grid = mySlick.getGrid('#DefineParametersGrid', data, columns, options);

Hi this issue seems to have solved itself after updating our version of JQuery to the latest version. I'm not sure what caused it or why it was happening but is is fixed now.

Related

Jqgrid filtering not working for complete word and data

Filtering of jqgrid client side. The Problems iam facing are:
Filtering is working only in two columns(Project Ref and Project name in the below code) and only or some part of the word.
Filtering is not working for the data which is coming another table. I am using two datatables for retrieving of data. Works only for the direct table doesnt work for referenced table data.
Can I have theesearch without Loadonce true.Because it is not allowing to reload
I have tried with the following below code let me know where iam doing wrong
In view:
$(document).ready(function () {
$("a.button").button();
var url = '#Url.Action("ListAllProjects")' + '?s_partId=' + '#ViewBag.PartId';
var colNames = ['<input type="checkbox" onclick="CheckAll(this.checked,\'chkOF_\',event);" name="checkall">',
'Status',
'Project Ref',
'Project Name',
'Customer',
'CreatedBy',
'Creation Date',
'Last Modified',
'LastModifiedDate',
'Edit'];
var colModel = [
{ name: 'ProjectId', index: 'ProjectId', align: 'left', formatter: checkFormatter, width: 20, search: true },
{ name: 'ProjectStatusId', index: 'ProjectStatusId', edittype: 'image', align: 'left', width: 70, formatter: imageFormatter, search: true },
{ name: 'ProjectReference', index: 'ProjectReference', align: 'left', width: 100, formatter: 'showlink', formatoptions: { "baseLinkUrl": "/Ordernew/Home" }, search: true },
{ name: 'ProjectName', index: 'ProjectName', align: 'left', width: 150, formatter: 'showlink', formatoptions: { "baseLinkUrl": "/Ordernew/Home" }, search: true },
{ name: 'CustomerName', index: 'CustomerName', align: 'left', width: 150, search: true },
{ name: 'CreatedBy', index: 'CreatedBy', align: 'left', width: 150, search: true },
{ name: 'CreationDate', index: 'CreationDate', align: 'left', width: 100, formatter: 'date', formatoptions: { srcformat: 'ISO8601Long', newformat: 'd-M-y h:m A' }, search: true },
{ name: 'LastModifiedBy', index: 'LastModifiedBy', align: 'left', width: 100, search: true },
{ name: 'LastModifiedDate', index: 'LastModifiedDate', align: 'left', width: 100, formatter: 'date', formatoptions: { srcformat: 'ISO8601Long', newformat: 'd-M-y h:m A' }, search: true },
{ name: 'StatusId', index: 'ProjectStatusId', formatter: myCustomFormatter, align: 'left', width: 70, search: true },
];
var sortname = 'ProjectStatusId';
var sortorder = 'desc';
SetGrid('#jqgprojectnew', '', url, colNames, colModel, sortname, sortorder, -1,'#count',true);
$("#jqgprojectnew").jqGrid('filterToolbar',
{
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
});
And setting the grid like this which is common for all the grids. But i need search only for the above grid:
function SetGrid(v_gridCtrl,v_pagingCtrl, v_url, v_colNames, v_colModel, v_sortname, v_sortorder, v_Pagesize,Count,Loadonce) {
if (v_Pagesize == undefined)
v_Pagesize = 100;
$(v_gridCtrl).jqGrid({
//url from wich data should be requested
autowidth: true,
url: v_url,
//type of data
datatype: 'json',
//url access method type
mtype: 'POST',
//columns names
colNames: v_colNames,
//columns model
colModel: v_colModel,
//pager for grid
pager: $(v_pagingCtrl),
//enable dynamic scrolling
//scroll: true,
//enable npage request parameter
prmNames: { npage: 'npage' },
//number of rows per page
rowNum: v_Pagesize,
rowList: [10, 30, 60, 90, 100, 150, -1],
loadComplete: function () {
$("option[value=-1]").text('All');
$(Count).html($(v_gridCtrl).getGridParam("reccount"));
},
loadonce:Loadonce,
//initial sorting column
sortname: v_sortname,
//initial sorting direction
sortorder: v_sortorder,
//we want to display total records count
viewrecords: true,
//grid height
height: 400,//'100%',
//width: '100%',
scrollOffset: 0,
shrinkToFit: true,
});
}
Code for Adding record :
public bool AddUpdateOrderField(ProjectViewModelNew obj)
{
var rec = new Project
{
ProjectID = Guid.NewGuid(),
ProjectDetail = obj.ProjectDetail,
CustomerId =obj.Id,
ProjectName = obj.ProjectName,
CreatedBy = new UserManager().Userid(),
CreationDate = DateTime.Now,
LastModifiedBy = new UserManager().Userid(),
ProjectRef = obj.ProjectRef,
ProjectStatusId = obj.ProjectStatusId,
LastModifiedDate = DateTime.Now,
OwnerID = new Guid("BEBB9E61-1F06-4762-80D8-5E4D554EAEB5")
};
_context.Projects.AddObject(rec);
_context.SaveChanges();
return true;
}
If you are using local search, you should set loadonce =true and it doesn't matter, from how many tables your data is fetched to the jqgrid. If you want to make loadonce=false, then you should post search criteria to server and perform a database search.
And try removing stringResult: true, to solve your first issue
To make the search case insensitive, add this to jqgrid properties:
ie ;
$(v_gridCtrl).jqGrid({
//url from wich data should be requested
autowidth: true,
.....
ignoreCase:true,
...}
And to reload the grid, try the following code:
$( v_gridCtrl ).trigger( 'reloadGrid', [{ page: 1}] );

How to refresh jqgrid using the response data returned from the edit

I am using the inlineNav edit options for Adding and Editing rows. The data is being updated to the database correctly, but I can't find a way to refresh the grid after a successful save without posting back to the server.
All of the Questions & Answers that I find recommend doing
$.('grid').trigger('reloadGrid');
But that seems unnecessary if the response from the server already contains the required data. It is primarily an issue when adding a new record and the ID value is displayed as jqg1.
I am using ASP.NET MVC4, with jqGrid 4.4.4.
Here is my view
$(document).ready(function () {
var emptyMsgDiv = $('<div>No school codes to display.</div>');
var grid = $('#tblSchools');
grid.jqGrid({
datatype: 'json',
viewrecords: true,
url: '#Url.Action("SchoolsGridData")',
editurl: '#Url.Action("EditSchoolsGridData")',
colNames: ['School ID', 'Name', 'SACE Number', 'School Code', 'LEA Code', 'DFEE Code', 'Active'],
colModel: [
{ name: 'SchoolId', index: 'SchoolId', width: 80, key: true },
{ name: 'Name', index: 'Name', width: 190, editable: true },
{ name: 'SaceSchoolNumber', index: 'SaceSchoolNumber', width: 105, editable: true, sortable: false },
{ name: 'Code', index: 'Code', width: 105, editable: true, sortable: false },
{ name: 'LeaCode', index: 'LeaCode', width: 80, editable: true, sortable: false },
{ name: 'DfeeCode', index: 'DfeeCode', width: 80, editable: true, sortable: false },
{ name: 'Active', index: 'Active', width: 80, editable: true, sortable: false }
],
shrinkToFit: true,
height: "100%",
caption: 'School list',
rowNum: 10,
rowList: [10, 15, 20],
emptyrecords: 'No school codes to display.',
pager: '#schoolsPager',
loadComplete: function () {
var count = grid.getGridParam();
var ts = grid[0];
if (ts.p.reccount === 0) {
grid.hide();
emptyMsgDiv.show();
} else {
grid.show();
emptyMsgDiv.hide();
}
}
}).trigger('reloadGrid', [{ page: 1 }]);
emptyMsgDiv.insertAfter(grid.parent());
grid.jqGrid('navGrid', "#schoolsPager", { edit: false, add: false, del: true });
grid.jqGrid('inlineNav', '#schoolsPager', {
addParams: {
position: "last",
addRowParams: {
"keys": true,
"aftersavefunc": function (rowid, response) {
alert('row: ' + rowid + ', response: ' + $.param(response));
}
}
},
editParams: {
"aftersavefunc": function (rowid, response) {
alert('row: '+rowid+', response: '+response);
}
}
});
});
</script>
<h3>Maintain Schools</h3>
<table id="tblSchools"></table>
<div id="schoolsPager" class="gridPager"></div>
and my Controller
public JsonResult EditSchoolsGridData(string oper, string SchoolId, string Name, string SaceSchoolNumber, string Code, string LeaCode, string DfeeCode, string Active)
{
[Update Logic]
return SchoolsGridData(string.Empty, "asc", 1, 10);
}
[HttpGet]
public JsonResult SchoolsGridData(string sidx, string sord, int? page, int? rows)
{
[Get data logic]
}
I can see the response json being displayed in the aftersavefunc, but can't find a way to bind it to the grid.
Is what I'm trying to do even possible?
You can use the addRowData method which will set the data to grid with our reloading the grid
jQuery("#tblSchools").jqGrid('addRowData', response.SchoolId, response, "first");
See the jqgrid methods wiki for more details

Passing rowIndex to a window in extjs 4

I have a store, a grid, a window and a few text boxes in the window. What I need is that on clicking the actioncolumn in the grid, i need to get the rowIndex of the clicked row and pass it to the window as a parameter. There, i need to load the store and get the values and set it in the appropriate textboxes. I'm not sure how to pass the rowIndex from grid to window on click. Wen I try to alert the value of a in the testfunction, it comes up as undefined. Pls help and below is my code.
Js File:
Ext.onReady(function() {
var rIx;
Ext.create('Ext.data.Store', {
storeId:'employeeStore',
fields:['firstname', 'lastname', 'senority', 'dep', 'hired'],
data:[
{firstname:"Michael", lastname:"Scott", senority:7, dep:"Manangement", hired:"01/10/2004"},
{firstname:"Dwight", lastname:"Schrute", senority:2, dep:"Sales", hired:"04/01/2004"},
{firstname:"Jim", lastname:"Halpert", senority:3, dep:"Sales", hired:"02/22/2006"},
{firstname:"Kevin", lastname:"Malone", senority:4, dep:"Accounting", hired:"06/10/2007"},
{firstname:"Angela", lastname:"Martin", senority:5, dep:"Accounting", hired:"10/21/2008"}
]
});
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
rIx=rowIndex;
//var rec = grid.getStore().getAt(rowIndex);
//alert("Edit " + rec.get('firstname'));
Ext.create('MyWindow').show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});
var testFunction = function(a){alert("a= "+a);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(a);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
};
Ext.define('MyWindow', {
extend: 'Ext.window.Window',
store : Ext.data.StoreManager.lookup('employeeStore'),
height: 250,
width: 250,
title: 'My Window',
items: [
{
xtype: 'textfield',
id : 'fname',
fieldLabel:'Name'
}
],
listeners: {
afterrender: Ext.Function.pass(testFunction, [rIx])
}
});
});
Ext.Function.pass(testFunction, [rIx]) takes the current value of rIx when pass is executed. The method is being called long before rIx is ever set to anything meaningful. Javascript is a pass-by-value language. It doesn't matter that eventually rIx gets set to the row index. By that point Ext.Function.pass has already been executed and the parameter it passed in was undefined.
Another approach is to just push the rowIndex onto your window as a property.
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
Ext.create('MyWindow', {rIx: rowIndex}).show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});
Ext.define('MyWindow', {
extend: 'Ext.window.Window',
store : Ext.data.StoreManager.lookup('employeeStore'),
height: 250,
width: 250,
title: 'My Window',
items: [
{
xtype: 'textfield',
id : 'fname',
fieldLabel:'Name'
}
],
listeners: {
afterrender: function(win){
alert("idx= " + win.rIx);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(win.rIx);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
}
}
});
Another option is to setup the window's afterrender listener in your handler function instead of adding it in the window's class definition. This approach is a bit cleaner in my opinion. I'm not a big fan of adding unrelated state properties to components.
Ext.create('Ext.grid.Panel', {
title: 'Employee Data',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{ text: 'First Name', dataIndex: 'firstname' },
{
header: 'Button',
xtype: 'actioncolumn',
icon : 'test.png',
handler: function(grid, rowIndex, colIndex, item, e , record) {
var win = Ext.create('MyWindow');
// add the listener after to avoid bashing any listener config
// that may already exist for the window.
win.on('afterrender', function() {
// rowIndex is available in the closure
alert("idx= " + rowIndex);
var r = Ext.data.StoreManager.lookup('employeeStore').getAt(rowIndex);
var firstname = r.get('firstname');
Ext.getCmp('fname').setValue(firstname);
});
win.show();
}
}
],
width: 500,
renderTo: Ext.getBody()
});

Extjs 4 cellEditor plugin Hanlde edit event

There's Ext grid panel with checkbox column.
The purpose is to handle checkbox cell click (which cell clicked & value)
Ext.define('App.Model.Users', {
extend: 'Ext.data.Model',
fields: ['Id', 'Login', 'Fio', 'Organization', 'Locked']
});
var usrstore = Ext.create('App.Data.Lstore', {
model: 'App.Model.Users',
autoLoad: false,
proxy: {
type: 'ajax',
url: '/Admin/GetUsers'
}
});
var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: { edit: function(editor, e){console.log('gf')} }
});
var usrgrid = Ext.create('Ext.grid.Panel', {
height: 600,
store: usrstore,
columns: [
Ext.create('Ext.grid.RowNumberer'),
{ dataIndex: 'Login', width: 300, text: 'Логин' },
{ dataIndex: 'Fio', flex: 1, width: 250, text: 'Фамилия И. О.' },
{ dataIndex: 'Organization', flex: 2, width: 200, text: 'Организация' },
{ dataIndex: 'Locked', width: 120, text: 'Блокировка', xtype: 'checkcolumn', align: 'center'}]
});
But no edit event from plugin comes..
What config grid plugin need to start work?
You need to set your 'cellEditing' in the plugins:[] config. You might also want to specify and editor (text,date,number, etc) on each column that you want to edit. See sencha examples for this stuff. Also checkbox is a Row selector not a cell selector - just something to keep in mind.

binding sql data with jquery grid usin g handler file

i have a jquery grid which has to be binded with values from sql data,
i have the following code where i would get the data to be binded to the grid in "data1 " variable.the problem i dont know how to bind the data to the jquery grid
$(document).ready(function() {
var data1 = "";
$.ajax({
datatype: 'json',
url: 'Handler1.ashx?method=Ttest',
success: function(val) {
debugger;
data1 = val;
}
});
$('#list').jqGrid({
mtype: 'GET',
colNames: ['key_user', 'UserName', 'Status', 'LoggedIn', 'LoggedOut', 'duration'],
colModel: [
{ name: 'key_user', index: 'key_user', width: 55 },
{ name: 'UserName', index: 'UserName', width: 90 },
{ name: 'Status', index: 'Status', width: 80, align: 'right' },
{ name: 'LoggedIn', index: 'LoggedIn', width: 80, align: 'right' },
{ name: 'LoggedOut', index: 'LoggedOut', width: 80, align: 'right' },
{ name: 'duration', index: 'duration', width: 150, sortable: false}],
sortname: 'invid',
sortorder: 'desc',
viewrecords: true,
caption: 'User Time Log Details'
});
});