Disable the NavGrid buttons in JQGrid when grid is empty - jqgrid-asp.net

I want to Disable the NavGrid buttons in JQGrid when grid is empty.
I am using the following code, but buttons are not getting disabled.
var rowCount = jQuery('#gridID').jqGrid('getGridParam', 'reccount');
if (rowCount == 0) {
$("view_" + "#gridID").addClass('ui-state-disabled');
$("refresh_" + "#gridID").addClass('ui-state-disabled');
}
Any help on this is highly appreciated.

I have resolved the above issue. See my below code:
var rowCount = jQuery('#gridID').jqGrid('getGridParam', 'reccount');
if (rowCount == 0) {
var grid = $("#gridID"),
gid = $.jgrid.jqID(grid[0].id);
var $viewBtn = $('#view_' + gid);
$viewBtn.addClass("ui-state-disabled");
var $refreshBtn = $('#refresh_' + gid);
$refreshBtn.addClass("ui-state-disabled");
}

Related

Add itemEditorValidatorFunction with Pop up window confirmation to Flexicious Grid

I am trying to have my Flexicious DataGrid ask for confirmation of a change when I click in a cell to edit a value and enter a new value which deviates from the original by a certain percentage. I cannot see an easy way to do this. Initially, I tried to write a itemEditorValidatorFunction, which returns a boolean. This works perfectly for a hard coded return value, but if I try to take the return value from the CloseEvent of an Alert, that value is ignored:
protected function validateGcCap(editor:UIComponent):Boolean{
var warningBPDiffVal:Number = Number(5);
var warningPerCentDiffVal:Number = Number(warningBPDiffVal / 1000);
var allowChange:Boolean = true;
var origGcCapVal:Number = Number(managerGrid.getCurrentEditingCell().text);
var newGcCapVal:Number = Number((editor as TextInput).text);
var diffVal:Number = Number(newGcCapVal - origGcCapVal);
if (origGcCapVal > newGcCapVal) {
diffVal = origGcCapVal - newGcCapVal;
}
if (diffVal > warningPerCentDiffVal) {
//Alert.show("you changed the gccap from " + origGcCapVal + " to " + newGcCapVal + " by " + diffVal);
function alertCloseHandler(event:CloseEvent):void{
if (event.detail == Alert.CANCEL) {
allowChange = false;
}
};
var alert:Alert = Alert.show("Are you sure that you want to update gcCap% by more than " + warningBPDiffVal + "bps?",
"Please Confirm", (Alert.OK | Alert.CANCEL),
this, alertCloseHandler);
}
return allowChange;
}
I also tried to write a itemEditor for the grids:FlexDataGridColumn, where I extended com.flexicious.controls.TextInput, but I could not work out which method to override. I wanted to override the method and only make the call to super if the Alert was clicked OK, but I could not see which method I should override. I tried override protected function onTextInput(textEvent:TextEvent):void, but this did nothing.
I would be grateful for any insight into this problem.
Not sure why someone decided to downvote your question, it seems quite valid. From looking at this, the best way for you would be to "undo" the edit when the user selects no on the box. If you have enableTrackChanges on, all you have to do is to remove that change from the dgGrid.changes collection and call dgGrid.refreshCells(). If you dont have enableTrackChanges, all you need to do is to update the dataProvider row with the old value, call dgGrid.refreshCells() and you should be set.
This is what works:
private function validateGcCap(editor:UIComponent):Boolean{
var warningBPDiffVal:Number = Number(5);
var cell:IFlexDataGridCell = managerGrid.getCurrentEditingCell();
var warningPerCentDiffVal:Number = Number(warningBPDiffVal / 1000);
var origGcCapVal:Number = Number(cell.text);
var newGcCapVal:Number = Number((editor as TextInput).text);
var diffVal:Number = Number(newGcCapVal - origGcCapVal);
if (origGcCapVal > newGcCapVal){
diffVal = origGcCapVal - newGcCapVal;
}
if (diffVal > warningPerCentDiffVal){
function alertCloseHandler(event:CloseEvent):void{
if (event.detail == Alert.CANCEL) {
IAParamsVO(cell.rowInfo.data).gcCapWrapper = origGcCapVal;
managerGrid.refreshCells();
}
}
Alert.show("Are you sure that you want to update gcCap% by more than "
+ warningBPDiffVal + "bps?", "Please Confirm", (Alert.OK | Alert.CANCEL),
this, alertCloseHandler);
}
return true;
}

EnhancedGrid get Selected cells

I'm working with EnhancedGrid and the selector plugin like here and I need to get every cell that is selected.
I was able to get the rows and columns like this:
var rows = grid.selection.getSelected('row', null);
var cols = grid.selection.getSelected('col', null);
But the following code doesn't work:
var cells = grid.selection.getSelected('cell', null);
Any help is welcome.
Thanks
Ok, this is my solution:
func = function(type, startPoint, endPoint, selected){
var cells = selected["cell"];
var cols = selected["col"];
var rows = selected["row"];
}
var handle =dojo.connect(grid, "onEndDeselect", func);
var handle = dojo.connect(grid, "onEndSelect", func);
Thankyou anyway

DevExpress ASPxComboBox Items Color Change from Code Behind

I have a ASPxComboBox for which I'm binding data based on 2 conditions.
Now,I need to show Color for items in combobox based on condition.
My Code :
var dataMainBranchUsers = (from xx in VDC.SURVEY_USER_DETAILS
where xx.BRANCH_ID == 1 && (xx.USER_LEVEL == 2 || xx.USER_LEVEL == 5)
select new
{
xx.USER_NAME,
xx.USER_ID,
xx.USER_LEVEL
}).ToList();
DataTable dtMainBranchUsers = LINQToDataTable(dataMainBranchUsers);
for (int i = 0; i < dtMainBranchUsers.Rows.Count; i++)
{
string strlevel = dtMainBranchUsers.Rows[i]["USER_LEVEL"].ToString();
string struser = dtMainBranchUsers.Rows[i]["USER_NAME"].ToString();
if (strlevel == "2")
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Admin";
}
else
{
dtMainBranchUsers.Rows[i]["USER_NAME"] = struser + " - Survey User";
}
}
Cmb_UserName.TextField = "USER_NAME";
Cmb_UserName.ValueField = "USER_ID";
Cmb_UserName.DataSource = dtMainBranchUsers;
Cmb_UserName.DataBind();
Now, I need to differentiate based on USER_LEVEL and show colors.
Is this possible?
From DevExpress
I'm afraid, the ASPxListBox (which is the part of the ASPxComboBox) doesn't allow to set specific color for each item.
I suggest you to use the ASPxDropDownEdit. This control allows to put anything in its DropDownWindowTemplateContainer.
For example, you can put the ASPxGridView and set color for each row using the HtmlRowPrepared event handler.
See here.

Dropdown remains empty -populating with json data

Hi im populating dropdown on change event of another dropdown from sql server using json data,
I got json data when i checked in firefox
but still my dropdown remains empty
Could somebody please help me what im doing wrong here
here is my code
function OnCathwordPopulated(response) {
var xx = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
$("#<%=ddlCatchword.ClientID %>").removeAttr("disabled");
$("#<%=ddlCatchword.ClientID %>").children().remove();
$("#<%=ddlCatchword.ClientID %>").empty().append("<option selected='selected' value='0'>Please select</option>");
var listItems = "";
for (var i = 0; i < xx.length; i++) {
var val1 = xx[i];
var text1 = xx[i];
listItems += "<option value='" + val1+ "'>" + text1 + "</option>";
} $("#<%=ddlCatchword.ClientID%>").html(listItems);
}
I used another method also
here is
$("#<%=ddlCatchword.ClientID%>").append($("<option></option>").val(val1).text(text));
I have tried this method to test out data
var h = ' <select name="test" id="ss" class="country" data-native-menu="false">';
h = h + listItems;
var w = window.open(); $(w.document.body).html(h);
And it opens new dropdwon with all json data in new window..
I dont know what strange thing is wrong ...
please note im using jquery mobile using asp.net
Modded the code to remove properly. I'm assuming this is selecting the correct list based off the code above. Also, a fiddle for example: http://jsfiddle.net/Tkt2B/
$("#<%=ddlCatchword.ClientID %>").removeAttr("disabled");
$("#<%=ddlCatchword.ClientID %>").find("option").remove().end()
$("#<%=ddlCatchword.ClientID %>").append("<option selected='selected' value='0'>Please select</option>");
var listItems = "";
for (var i = 0; i < xx.length; i++) {
var val1 = xx[i];
var text1 = xx[i];
listItems += "<option value='" + val1+ "'>" + text1 + "</option>";
}
$("#<%=ddlCatchword.ClientID%>").append(listItems);
it solved by using following trick,
$("#<%=ddlCatchword.ClientID%>").html(listItems); $("#<%=ddlCatchword.ClientID%>").selectmenu('refresh', true);
Got it working with the help from http://ozkary.blogspot.no/2010/12/jquery-mobile-select-controls-populated.html
Thanks!

Flex 4 Printing Error with dynamic components

I have a set of components that are added to my Flex 4 stage dynamically.
Problem 1:
How do I address these objects when adding them to print.I cant generate objects on the fly and append them because then the print manager does not wait for the dynamic data to populate.
I currently use the following code to address items dynamically which fails:
public function PrintDashPreview():void{
var ItemsDrawn:int = 0;
var printJob:FlexPrintJob = new FlexPrintJob();
if(printJob.start()){
for each (var item:Object in GetDashBoardPreviewItems.lastResult.DashboardItem)
{
ItemsDrawn ++
this.addElement(dashPreview["flexShape" + TheID]);
printJob.addObject(dashPreview["flexShape" + TheID]);
this.removeElement(dashPreview["flexShape" + TheID]);
}
printJob.send()
Alert.show('Sent: ' + ItemsDrawn + ' items to page for printing.','Print Progress Debug');
}
}
How can I tell flex to grab these specific items and add them to the print job.
Problem 2:
How do I tell flex to lay each item out one below the other 2 per page.
Please and thank you for any help you can provide.
Regards
Craig Mc
The recipe for printing dynamic content usually goes like this:
(1) Start the printJob:
printJob = new FlexPrintJob();
printJob.printAsBitmap = false;
printJob.start();
(2) Obtain the print page dimensions. Use it if you have overflowing content:
printerPageHeight = printJob.pageHeight;
printerPageWidth = printJob.pageWidth;
(3) Create all of the dynamic objects and wait for the corresponding CREATION_COMPLETE events:
var componentsToBeInitialized:Number = 0;
var pages:Array = [];
for each (var itemData:Object in dataProvider) {
var component:UIComponent = new PageComponent();
someContainerOnTheDisplayList.addChild(component);
component.data = itemData;
componentsToBeInitialized ++;
pages.push(component);
component.addEventListener(FlexEvent.CREATION_COMPLETE, handlePageCompletion);
}
(4) Waiting for all CREATION_COMPLETE events:
function handlePageCompletion(e:Event):void {
componentsToBeInitialized --;
if (componentsToBeInitialized == 0)
printAllPages();
}
(5) Print the pages:
function printAllPages():void {
for each (var printPage:UIComponent in pages) {
printJob.addObject(printPage);
}
printJob.send();
}

Resources