i am working in extjs4. I am adding paging functionality to grid. I am having my grid view code as-
allQuestionPapers.js
Ext.define('Balaee.view.qb.qbqns. ', {
extend : 'Ext.grid.Panel',
alias : 'widget.paperlist',
id : 'paperId',
store : 'qb.QbqnsStore',
border : false,
// height:autoheight,
width : 600,
autoScroll : true,
columns : [{
text : 'date',
width : 200,
dataIndex : 'createDate'
}, {
text : 'QuestionpaperNo',
width : 200,
dataIndex : 'questionPaperNo'
}, {
text : 'Marks',
width : 200,
dataIndex : 'obtainMarks'
}],
dockedItems : [{
xtype : 'pagingtoolbar',
id : 'pagingtoolbarId',
pageSize : 10,
dock : 'bottom',
displayInfo : true
}]
});
And in controller i am dynamically creating store and binding it to grid.For this i had written code as-
getAllPapers:function()
{
var paperlistStore=Ext.create('Balaee.store.qb.QbqnsStore',
{autoLoad: {params:{start:0, limit:10}}});
proxy= paperlistStore.getProxy();
Ext.apply(proxy.api,{
read:'index.php/QuestionBank/qbpaper/getUserAllQuestionPaper'
});
Ext.apply(proxy.reader,{
type:'json',
root:'questions'
});
Ext.apply(proxy.writer,{
type:'json',
root:'data'
});
var answers = '{"data":[';
answers = answers + '{"userId":1}';
answers =answers+']}';
console.log(answers);
paperlistStore.load({
params:{
data: answers
},
callback: function(records,operation,success){
console.log(records);
console.log("Successfully data send");
},
scope:this
});
var temp2=Ext.getCmp('QbqnsResultmainId');
temp2.removeAll();
var worldChaptor1 =Ext.create('Balaee.view.qb.qbqns.allQuestionPapers');
var resultView = Ext.getCmp('pagingtoolbarId');
console.log(resultView);
resultView.bindStore(paperlistStore);
temp2.add(worldChaptor1);
}
All this is working correctly.But grid is showing only 3 records per page instead of showing 25 records as per grid's paging function's dispaly message"displaying 1-25 of 280". So what changes i need to make in order to diaplay such 25 record per page.
Related
I have a strange issue with jQuery ui-sortable. In my example I have multiple columns and in each column I have multiple sortable items.
I want to drag and drop in any column, sorting within one column is no problem.
I have two problems:
When dragging from one column to another column I need the destination column to auto scroll to the bottom.
Horizontal scroll does not auto scroll for the column on the very right side.
See my example
https://jsfiddle.net/maidanhcongtu/9ws2unLa/11/
var configuration2 = {
cursor : 'move',
placeholder : 'highlight',
dropOnEmpty : true,
connectWith : ".connectedSortable",
containment : "body",
};
$(".connectedSortable").sortable(configuration2).disableSelection();
Okay, I have found a solution to disable scrolling when you're no longer sorting in the original parent, so that the sortable item does not scroll the parent when dragging over another sortable.
I also made the sortable list you're sorting over auto scroll to the bottom.
Sorry, I changed your code up a bit because it's easier for me to keep track of things this way.
Also, I added ID's to each sortable list.
see updated fiddle: https://jsfiddle.net/Souleste/ktxeu35p/46/
$('li').addClass('item');
var y;
var og;
var n, nB, half;
$(".connectedSortable").sortable({
cursor : 'move',
placeholder : 'highlight',
dropOnEmpty : true,
connectWith : ".connectedSortable",
containment : "body",
items: '.item',
start: function(event,ui) {
og = $(this).closest('.connectedSortable');
},
over: function(event,ui) {
n = $(this).closest('.connectedSortable');
nB = n.outerHeight(true) + n.position().top;
half = nB / 2;
},
sort: function(event,ui) {
console.log(half);
if ( n.attr('id') != og.attr('id') ) {
og.sortable( "option", "scroll", false );
if (event.pageY > half) {
n.scrollTop(n.scrollTop() + 5);
} else if (event.pageY < half) {
n.scrollTop(n.scrollTop() - 5);
}
} else {
og.sortable( "option", "scroll", true );
}
}
});
I am trying to add a tooltip on extjs overflow button, but I can't find a way to do that. It's not mentioned on docs either. Has anyone been able to do that? Either that or changing the text for the button
I found
overflowText: 'More >'
But this doesn't seem to work
You can add a tooltip to the overflow button during the afterrender event of the toolbar. The target element would be this.layout.overflowHandler.menuTrigger.el in the afterrender event.
Working jsFiddle http://jsfiddle.net/gJjTY/ (the overflow icon is in the bottom right of the toolbar, the icon isn't rendering due to lack of css)
Ext.create('Ext.toolbar.Toolbar', {
renderTo: document.body,
width : 300,
margin : '5 0 0 0',
layout : {overflowHandler: 'Menu' },
items : [
{
text : 'This is a Button',
tooltip: 'This is a tip',
},
{
text : 'This is another button',
},
{
text : "this is yet another button!"
}
],
listeners: {
afterrender: function(view){
var me = this;
console.log(me);
Ext.Function.defer(function(){
Ext.create('Ext.tip.ToolTip', {
target : me.layout.overflowHandler.menuTrigger.el,
anchor : 'left',
dismissDelay : 0,
showDelay : 0,
autoHide : true,
html : "This is a tooltip!"
});
}, 100);
}
}
});
Ext.onReady(function(){
Ext.QuickTips.interceptTitles = true;
Ext.QuickTips.init();
});
How can I achieve to keep my custom filter row in synch with column reordering and column hiding? I am currently investigating Telerik kendo UI grid v2013.1.514.
The code is as follows:
var grid = $("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.kendoui.com/service/Northwind.svc/Products"
},
pageSize: 15,
serverPaging: true,
serverSorting: true,
serverFiltering: true
},
height: 450,
reorderable: true,
pageable: true,
columns: [{ field: "ProductID"}, { field: "ProductName"}, { field: "UnitPrice"}]
});
var filterRow = $('<tr><td><input type="search" id="ProductIDSearchBox" value="EnterProductID"/></td>' +
'<td><input type="search" id="ProductNameSearchDD" value="Enter ProductName"/></td>' +
'<td><input type="search" id="UnitPriceSearchBox" value="Enter UnitPrice"/></td></tr>');
grid.data("kendoGrid").thead.append(filterRow);
Please find an example here: http://jsfiddle.net/WrqmD/4/.
Just drag'n'drop the column headers around and see that the custom filter row is NOT reordered!
EDIT:
Btw., the solution to append the custom filter is described here: http://www.kendoui.com/forums/kendo-ui-web/grid/grid-header-filtering-row-that-contains-1-element-for-each-column-in-grid-with-the-same-width.aspx
After coresponding with the Telerik Support I would like to share the solutions below:
Implementing the columnReorder event adding the following method declaration to the grid options. This was suggested by Telerik Support. Please find a working JsFiddle demo here:
columnReorder: function(e) {
var selector = this.thead.find(".filterRow td"),
source = selector.eq(e.oldIndex),
dest = selector.eq(e.newIndex);
source[e.oldIndex > e.newIndex ? "insertBefore" : "insertAfter"](dest);
}
Append the Custom Elements to the original header elements. This is my own solution where I go with, because both reordering and hiding of columns is solved with the same code. Please find a working JsFiddle demo here:
var columns = grid.data("kendoGrid").columns;
for(var i = 0; i < columns.length; i++) {
var column = columns[i];
var columnName = column.field;
var columnHeader = $('div#grid th.k-header[data-field="' + columnName + '"]');
if(undefined != columnHeader[0]) {
var fieldValue = $('<input type="text" style="display:block;">');
fieldValue.val(columnName);
fieldValue.click(function(evt) {
evt.stopPropagation();
$(evt.target).focus().select();
});
columnHeader.append(fieldValue);
}
}
I've been trying to learn Sencha Touch and I'm stuck on something that is probably pretty obvious. I'm trying to update a tabPanel with a button event. I'd like for a tap on the first button to load 'maptestPanel' in the same panel. This is a map loaded from its own js file.
The map panel looks ok by itself:
maptestPanel = new Ext.Panel({
layout: 'fit',
fullscreen: true,
items: [map]
});
But I'm not seeing how to properly place it in the tabPanel
The code is:
Ext.setup({
icon: 'icon.png',
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
glossOnIcon: false,
onReady: function() {
var navBar = new Ext.Toolbar({
dock : 'top',
title: 'Some App Name',
});
var topPanel = new Ext.Panel({
dockedItems: [navBar],
fullscreen : true,
//html: 'Test Panel'
});
var tapHandler = function(button, event) {
btnPanel.update(maptestPanel); //I'm sure part of the problem is here
}
var SomeDate1 = new Ext.Button({
text:"Some date",
minWidth:200,
height: 45,
cls:"listButtonTop",
handler:tapHandler
});
var SomeDate2 = new Ext.Button({
text:"Another Date",
minWidth:200,
height: 45,
cls:"listButton"
});
var SomeDate3 = new Ext.Button({
text:"And Another Date",
minWidth:200,
height: 45,
cls:"listButtonBottom"
});
var btnPanel = new Ext.Panel ({
id: 'date',
items: [SomeDate1,SomeDate2,SomeDate3],
});
var tabpanel = new Ext.TabPanel({
layout: 'card',
tabBar: {
dock: 'bottom',
layout: {
pack: 'center'
}
},
fullscreen: true,
ui: 'dark',
cardSwitchAnimation: {
type: 'slide',
cover: true
},
defaults: {
scroll: 'vertical'
},
items: [{
title: 'Maps',
//html: '<h1>Place holder</h1>',
iconCls: 'maps',
cls: 'card1',
items: [btnPanel]
}, {
title: 'Favs',
html: '<h1>Place holder</h1>',
iconCls: 'favorites',
cls: 'card2',
badgeText: '4',
layout: 'fit'
//items: [SomeList, SomeOtherList, AnotherList]
}, {
title: 'Info',
html: '<h1>Place holder</h1>',
cls: 'card4',
iconCls: 'info'
}]
});
}
});
Thanks for any advice or a steer in the right direction.
There's several things you need to do to fix up that code:
1) 'Maps' has no layout. Since it has a single child item, layout: 'fit' would be appropriate here.
2) Only use fullscreen on the outermost item, you don't want the other items to be fullscreen since they are child items of other containers.
3) To dynamically add items to a container, use the add() method on container. You'll also need to call doLayout() to trigger a layout for the container.
btnPanel.add(maptestpanel);
btnPanel.doLayout();
However, in this case I don't see why you're adding the map to a panel, it doesn't give you any extra functionality. Instead, I would add the map directly to the btnPanel.
4) The btnPanel has no layout either, so you'll need to choose an appropriate layout there as well, possibly the vbox layout.
I only know "classic" sencha, but this should work the same way : So you could just add the mapPanel (but hidden) to your tabPanel, and in the button handler show it while hiding the button panel.
Besides, speaking of layouts, I don't think you need to precise layout:'card' in tabPanel since it uses a card layout by definition
My requirement is to show a page with multiple filters to apply to grid data.
Suppose we are talking about Orders and an order has the following attributes
public class Order {
public int OrderID
public DateTime OrderDate
public DateTime ShipmentDate
public int OrderTotal
public int OrderStatus
}
Inside the jqgrid object I am showing all the attributes except the OrderStatus
The requirement is to create a view that has
the jqGrid on the left part
a panel on the right
Inside the right panel the user will see a list of checkboxes that represents every possible OrderStatus value and he want to search using both methods (for example selecting the checkbox "Shipped Orders" and then filtering the grid with Amount greater than a value)
I have already configured the advanced filtering (multiplesearch:true) inside the jqGrid object and I am able to create complex filters combining fields and logical operators.
Any ideas on how I can submit even the data from the right panel when the user press the search button?
Update 1:
Preamble: Oleg sample is fantastic but unfortunately does not fits requirements of my customer :(
#Oleg: I do not understand why you think that:
If the data are outside of the grid
you will be show the order details on
the right pane only for selected row.
So the user will have not so good
overview of the data.
maybe my description was not so clear but I am not going to show any order detail. To better clarify my requirement I have modified your sample to show you the desired final UI which is as in the following image:
The customer want to filter the data in the grid using two methods or both together:
Using the multiplesearch facilities provided by the grid itself (thanks for the workaround mention)
Using the custom Search Panel (the one with the checkboxes on the right) provided
From a functional point of view the requirement is very easy to express: When the user click on a checkbox or make a search using the native multiplesearch I should post values to the server including also the checkboxes state.
To summarize I should:
Add the checkboxes state when a post is made through the native multiplesearch
Add the current multiplesearch state (if any) when the user click on a checkbox
Is there a way to do this?
I understand this requirement very good. In the close case I used checkboxes inside of jqGrid. The most advantage to having the information inside of jqGrid is not only the possibility of easy searching. If the data are outside of the grid you will be show the order details on the right pane only for selected row. So the user will have not so good overview of the data.
To be able to place many checkboxes in the table without permanent horizontal scrolling I rotated headers of the columns having "checkbox with the technique described in Vertical text inside table headers using a JavaScript-based SVG library. This rotation looks not perfect in IE, but in other browser it works perfect.
You can hold the data from the OrderStatus field in a hidden column and decode the bitmask to boolean which build checkboxes either on the client or on the server side.
Because use want to use multiplesearch:true I have to mention about a bug in jQuery.clone which follow to the bug in jqGrid multi-search in all versions of IE browsers. If you define more as one search filters only the first one will be used because the operation field of all other filters will be read as undefined. It's a pity, but the bug is also not fixed in the jQuery 1.4.3 just published. To be able to use multiplesearch:true you can use workaround suggestion by Jiho Han on trirand.com forum.
All together you can see in the demo example which produce the grid
where you can search for multiple fields
The corresponding code:
var myData = [
{ orderID: "10", orderDate: "2010-09-18", shipmentDate: "2010-09-20", orderStatus: "2" },
{ orderID: "15", orderDate: "2010-09-20", shipmentDate: "2010-09-24", orderStatus: "3" },
{ orderID: "20", orderDate: "2010-10-16", shipmentDate: "2010-10-17", orderStatus: "1" }
];
// decode 'orderStatus' column and add additional boolean data based on the bitmap mask
for (var i=0, l=myData.length; i<l; i++) {
var myRow = myData[i];
var orderStatus = parseInt(myRow.orderStatus, 10);
myRow.airPost = (orderStatus & 2) != 0? "1": "0";
myRow.heavy = (orderStatus & 1) != 0? "1": "0";
}
var grid = jQuery('#list');
grid.jqGrid({
data: myData,
datatype: 'local',
caption: 'Order Details',
height: 'auto',
gridview: true,
rownumbers: true,
viewrecords: true,
pager: '#pager',
rownumbers: true,
colNames: ['Order ID', 'Order', 'Shipment', 'Air-Post', 'Heavy', 'RowVersion'],
colModel: [
{ name: 'orderID', index: 'orderID', key:true, width: 120, sorttype: 'int' },
{ name: 'orderDate', index: 'orderDate', width: 180,
sorttype: 'date', formatter: 'date' },
{ name: 'shipmentDate', index: 'shipmentDate', width: 180,
sorttype: 'date', formatter: 'date' },
{ name: 'airPost', width: 21, index: 'airPost', formatter: 'checkbox', align: 'center',
editoptions: { value: "1:0" }, stype: 'select', searchoptions: { value: "1:Yes;0:No" } },
{ name: 'heavy', width: 21, index: 'heavy', formatter: 'checkbox', align: 'center',
editoptions: { value: "1:0" }, stype: "select", searchoptions: { value: "1:Yes;0:No" } },
{ name: 'orderStatus', index: 'orderStatus', width: 50, hidden: true }
]
}).jqGrid ('navGrid', '#pager', { edit: false, add: false, del: false, refresh: true, view: false },
{},{},{},{multipleSearch:true})
.jqGrid ('navButtonAdd', '#pager', { caption: "", buttonicon: "ui-icon-calculator", title: "choose columns",
onClickButton: function() {
grid.jqGrid('columnChooser');
}
});
where rotateCheckboxColumnHeaders and the bugfix in the advanced search defined so
// we use workaround from http://www.trirand.com/blog/?page_id=393/bugs/in-multiple-search-second-and-subsequent-ops-are-sent-as-undefined-in-ie6/
// to fix the bug in the jQuery.clone (see http://bugs.jquery.com/ticket/6793 and
// dscussion on the http://api.jquery.com/clone/
jQuery.event.special.click = {
setup: function() {
if (jQuery(this).hasClass("ui-search")) {
jQuery(this).bind("click", jQuery.event.special.click.handler);
}
return false;
},
teardown: function() {
jQuery(this).unbind("click", jQuery.event.special.click.handler);
return false;
},
handler: function(event) {
jQuery(".ui-searchFilter td.ops select").attr("name", "op");
}
};
var rotateCheckboxColumnHeaders = function (grid, headerHeight) {
// we use grid as context (if one have more as one table on tnhe page)
var trHead = jQuery("thead:first tr", grid.hdiv);
var cm = grid.getGridParam("colModel");
jQuery("thead:first tr th").height(headerHeight);
headerHeight = jQuery("thead:first tr th").height();
for (var iCol = 0; iCol < cm.length; iCol++) {
var cmi = cm[iCol];
if (cmi.formatter === 'checkbox') {
// we must set width of column header div BEFOR adding class "rotate" to
// prevent text cutting based on the current column width
var headDiv = jQuery("th:eq(" + iCol + ") div", trHead);
headDiv.width(headerHeight).addClass("rotate");
if (!jQuery.browser.msie) {
if (jQuery.browser.mozilla) {
headDiv.css("left", (cmi.width - headerHeight) / 2 + 3).css("bottom", 7);
}
else {
headDiv.css("left", (cmi.width - headerHeight) / 2);
}
}
else {
var ieVer = jQuery.browser.version.substr(0, 3);
// Internet Explorer
if (ieVer !== "6.0" && ieVer !== "7.0") {
jQuery("span", headDiv).css("left", 0);
headDiv.css("left", cmi.width / 2 - 4).css("bottom", headerHeight / 2);
}
else {
headDiv.css("left", 3);
}
headDiv.parent().css("zoom",1);
}
}
}
};
If you do prefer to hold the checkboxes outside of the grid you can do the decoding of the bit-mask OrderStatus inside of onSelectRow event handler.
UPDATED: I really something misunderstood your requirements at the beginning. Look at the modified example. Now it looks like
and it is more close to what you need.
Just as a follow up I am including here another method that I have found to abtain the same result.
This method suppose to use the postData parameter of jqGrid. Inside the method I have defined various function that verify the checkboxes current status and sends a parameter to the server where it can be used for filtering.
This is a sample
postData: {
pending: function () {
if ($("#cb_pending").is(':checked')) {
return true;
} else {
return false;
}
}
}
The advantage of this solution respect to the one depicted by Oleg is that it is possible to use mixed logical operators (AND/OR) on the server side whereas using the filters section as in the Oleg answer it is not possible.
Happy coding!