h1

Remove invalid characters from file name and path

February 4, 2015

Code :

string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());

foreach (char c in invalid)
{
strFileName = strFileName.Replace(c.ToString(), “”);
}

h1

Check a classname exist

January 29, 2015

Check the html object is having a particular class :

if($.inArray(‘classname’, $(obj)[0].classList) > -1)
{
///class is available
}
h1

jqGrid Functions

October 3, 2014

Set Sorting :

$(“#tblJqGrid”).jqGrid(‘setGridParam’, {sortname:’columnname’, sortorder: ‘sordorder’ });
$(‘#tblJqGrid’).trigger(“reloadGrid”, [{ page: 1 }]);

Another Option :
$(“#tblJqGrid”).sortGrid(‘columnname’, reload);
reload is boolean(true/false) param.

Get current sorted column & order :

$(“#tblJqGrid”).jqGrid(‘getGridParam’, ‘sortname’);
$(“#tblJqGrid”).jqGrid(‘getGridParam’, ‘sortorder’);

Set jqGrid Data :

$(“#tblJqGrid”).jqGrid(‘setGridParam’, { data: jsonObjGridData });

Clear jqGrid Data :

$(“#tblJqGrid”).jqGrid(‘clearGridData’);

Show/Hide Columns :

$(“#tblJqGrid”).jqGrid(‘showCol’, [‘Column1’, ‘Column2’];
$(“#tblJqGrid”).jqGrid(‘hideCol’, [‘Column1’, ‘Column2’];

Resize jqGrid :

$(“#tblJqGrid”).jqGrid(‘setGridWidth’, , true).trigger(‘resize’);
$(“#tblJqGrid”).jqGrid(‘setGridHeight’, , true).trigger(‘resize’);

Reload jqGrid :

$(‘#tblJqGrid’).trigger(“reloadGrid”, [{ page: 1 }]);

Clear all values in search Toolbar :

$(“#JqGridId”)[0].clearToolbar();

Get value from cell :

var value = $(“#tblJqGrid”).jqGrid(‘getCell’, rowId, ‘ColumnName’ );

Set value to cell :

$(“#tblJqGrid”).jqGrid(‘setRowData’, rowId, { ColumnName: data });

 

h1

Add new filter in jqGrid tool bar search

October 3, 2014

Code :

$(“#tblJqGrid”).jqGrid(‘filterToolbar’, {
stringResult: true, searchOnEnter: true, autosearch: true, enableClear: false,
afterSearch: function () {
if (myfilter != null) {
var myRules = “”;
var _SearchFilter = “”;

///creating new filter
myRules += “,{\”field\”:\”” + + “\”,\”op\”:\”” + + “\”,\”data\”:\”” + + “\”}”;
myRules += “]}”;

if ($(“#tblJqGrid”)[0].p.postData._search != false) {///append new filter in tool bar search filter

_SearchFilter = $(“#tblJqGrid”)[0].p.postData.filters.replace(“]}”, myRules);

$(“#tblJqGrid”).jqGrid(“getGridParam”, “postData”).filters = _SearchFilter;
$(“#tblJqGrid”).trigger(“reloadGrid”, [{ page: 1 }]);
}
else {

$(“#tblJqGrid”).jqGrid(‘setGridParam’, {
postData: { filters: },
search: true
});
$(“#tblJqGrid”).trigger(“reloadGrid”, [{ page: 1 }]);
}
}
}
});

 

h1

ignore case in replace C#

July 3, 2014

we can ingnore case in replacing test using Regex

to use Regex include System.Text.RegularExpressions header file

Coding :

Regex.Replace(string,TextToRemove,string.Empty,RegexOptions.IgnoreCase);

h1

Trigger Events : Flash Action Script

June 19, 2014

we can trigger any of the object’s event in another object event

Coding :

btnAnother.addEventListener(MouseEvent.CLICK, btnAnotherClick);
function btnAnotherClick(event:MouseEvent) 
{
	/// your code
}

btnOne.addEventListener(MouseEvent.CLICK, btnOneClick);
function btnOneClick(event:MouseEvent) 
{
   btnAnother.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
   /// Can trigger any event like MOUSE_OVER,MOUSE_OUT.... 
}

h1

JqGrid cell click using column name

April 19, 2013

We can use onCellSelect to set click function and can use getGridParam – colModel to get which column cells to have click function.

Coding :

onCellSelect: function(rowid, index, contents, event) 
{    
   var cm = $("#list1").jqGrid('getGridParam','colModel');                          
   if(cm[index].name == "ColumnName")
   {
       fnName(rowid);
   }
}