shift select records in gridview asp.net - asp.net

hey guys,
i have a gridview which displays 10records per page, now i want to implement shift+click option in my gridview, when user clicks on the first row and press shift key and click on the 5th row, all the rows between 1 and 5(1 and 5 inclusive) should be selected...
can anyone suggest how should i do this in javascript.

I take it back, I found a shift+click multiple select solution for a gridview. All credit goes to mdv over at the asp forums.
var _sPreviousRow = null;
function wsCheckRange(p_oGridView, p_oControl, e) {
var l_sCheckID = p_oControl.id;
var l_aCheckIDParts = l_sCheckID.split(p_oGridView.id);
var l_sCurrentRow = l_aCheckIDParts[1].split('_')[1].substring(3);
var l_oEvent = (window.event) ? event : e;
if (l_oEvent.shiftKey) {
if (_sPreviousRow != null && _sPreviousRow != l_sCurrentRow) {
var l_iFirst = 0, l_iLast = 0;
if (parseInt(_sPreviousRow,10) > parseInt(l_sCurrentRow,10)) {
l_iFirst = parseInt(l_sCurrentRow,10);
l_iLast = parseInt(_sPreviousRow,10);
}
else {
l_iFirst = parseInt(_sPreviousRow,10);
l_iLast = parseInt(l_sCurrentRow,10);
}
for (var i = l_iFirst; i < l_iLast; i++) {
var l_sLastRow = (i <= 9 ? '0' + i : i);
var l_sCtrlNew = l_sCheckID.replace('ctl' + l_sCurrentRow, 'ctl' + l_sLastRow);
var l_oCtrlNew = $get(l_sCtrlNew);
if (l_oCtrlNew) {
l_oCtrlNew.checked = p_oControl.checked;
}
}
}
_sPreviousRow = null;
}
else {
_sPreviousRow = l_sCurrentRow;
}
}

Related

How to populate data related to an item from the location which is same for all items in Xamarin.forms

I am developing an xamarin.forms app ,I have various fields like Item Name ,Item Number and location ,here Location of all the items are same ,by entering names or number of the items the values are generated automatically because name and number are unique but since the location number is common is for all the items I am not able to populate correct data related to a particular field ,I am using sqlite database in my project can anyone please suggest me on what basis can I generate related values ?
Here is the code
public async void OnSearch_Location(object o, EventArgs args)
{
if (location.Text == string.Empty || location.Text == null)
{
await Navigation.PushAsync(new ListValuePage("Location", filePath,
pos, list));
}
else
{
for (int p = 0; p < list.Count; p++)
{
if (list.ElementAt(p).Aisle + "." + list.ElementAt(p).Bin +
"." + list.ElementAt(p).Level == location.Text)
{
line.Text =
Convert.ToString(list.ElementAt(p).Line_Number);
location.Text = list.ElementAt(p).Aisle + "." +
list.ElementAt(p).Bin + "." + list.ElementAt(p).Level;
item.Text = list.ElementAt(p).Item_Number;
name.Text = list.ElementAt(p).Name;
if (list.ElementAt(p).Order_Qty == 0)
{
order_uom.Text = "";
}
else
{
order_qty.Text =
Convert.ToString(list.ElementAt(p).Order_Qty);
}
order_uom.Text = list.ElementAt(p).Order_UOM;
if (list.ElementAt(p).Consumption_UOM == string.Empty ||
list.ElementAt(p).Consumption_UOM == null)
{
consume_lbl.IsVisible = false;
consume_qty.IsVisible = false;
consume_uom.IsVisible = false;
}
else
{
consume_lbl.IsVisible = true;
consume_qty.IsVisible = true;
consume_uom.IsVisible = true;
if (list.ElementAt(p).Consumption_Qty == 0)
{
consume_qty.Text = "";
}
else
{
consume_qty.Text =
Convert.ToString(list.ElementAt(p).Consumption_Qty);
}
consume_uom.Text = list.ElementAt(p).Consumption_UOM;
}
}
}
}
}

web api call performance tuning

I am trying to figure find why my api is taking ~5 secs working on 1000 records,is that good or bad?I want to know what tools are there in asp.net webapi to figure out which piece of code or where its consuming time and fine tune the performance
CODE:-
List<LookaheadRunInfo> lookaheadRunsInfo = new List<LookaheadRunInfo>();
List<lookahead_run> lookaheadRunData = new List<lookahead_run>();
if (!filterCriteria.labeled)
{
lookaheadRunData = bitDB.lookahead_run.Where(x => x.lookahead_run_status == null && x.submission_time != null).OrderByDescending(x => x.submission_time).Skip(filterCriteria.PageNumber * filterCriteria.PageSize).Take(filterCriteria.PageSize).ToList();
}
else
{
lookaheadRunData = bitDB.lookahead_run.OrderByDescending(x => x.submission_time).Skip(filterCriteria.PageNumber * filterCriteria.PageSize).Take(filterCriteria.PageSize).ToList();
}
foreach (var lookaheadRunRow in lookaheadRunData)
{
var lookaheadRunInfo = new LookaheadRunInfo();
var lookaheadRunId = lookaheadRunRow.lookahead_run_id;
lookaheadRunInfo.ECJobLink = lookaheadRunRow.ec_job_link;
lookaheadRunInfo.UserSubmitted = lookaheadRunRow.submitted_by;
lookaheadRunInfo.SubmittedTime = lookaheadRunRow.submission_time.ToString();
lookaheadRunInfo.RunStatus = lookaheadRunRow.lookahead_run_status;
var completionTime = lookaheadRunRow.completion_time;
if (completionTime == null)
{
lookaheadRunInfo.ElapsedTime = (DateTime.UtcNow - lookaheadRunRow.submission_time).ToString();
}
else
{
lookaheadRunInfo.ElapsedTime = (lookaheadRunRow.completion_time - lookaheadRunRow.submission_time).ToString();
}
List<String> gerrits = new List<String>();
List<string> lookaheadRunChangeListIds = new List<string>();
if (!filterCriteria.labeled)
{
lookaheadRunChangeListIds = (from lrcl in bitDB.lookahead_run_change_list
join cl in bitDB.change_lists on lrcl.change_list_id equals cl.change_list_id
where lrcl.lookahead_run_id == lookaheadRunId
//and cl.change_list_id not in (select clcl.change_list_id from component_labels_change_lists as clcl)
//where !(from clcl in bitDB.component_labels_change_lists select clcl.change_list_id).Contains(cl.change_list_id)
where !bitDB.component_labels_change_lists.Any(clcl => clcl.change_list_id == cl.change_list_id)
select cl.change_list.ToString()).ToList();
}
else
{
lookaheadRunChangeListIds = (from lrcl in bitDB.lookahead_run_change_list
join cl in bitDB.change_lists on lrcl.change_list_id equals cl.change_list_id
where lrcl.lookahead_run_id == lookaheadRunId
select cl.change_list.ToString()).ToList();
}
//bitDB.Log = Console.Out;
//lookaheadRunInfo.gerrits = gerrits;
lookaheadRunInfo.gerrits = lookaheadRunChangeListIds;
if (lookaheadRunChangeListIds.Count != 0 && filterCriteria.labeled == false)
{
lookaheadRunsInfo.Add(lookaheadRunInfo);
}
else if (filterCriteria.labeled == true)
{
lookaheadRunsInfo.Add(lookaheadRunInfo);
}
}
return lookaheadRunsInfo;

There is no row at column 0

I'm having one grid and one link button on that grid which have rowcommand but whenever i click on that button it shows me error that there is no row at column 0.
i've debugged whole code so many time but always it's showing me that there is no column even if there is data in that specific column of dataset.
I'm new to asp.net as well as to sql so only knowing that how to put code but logic is not getting cleared please can anyone clear this query. your help is too much for me.
protected void grdManageBRProperty_RowCommand(object sender, GridViewCommandEventArgs e)
{
Session["prptIdBRP"] = e.CommandArgument.ToString();
string id = Session["prptIdBRP"].ToString();
ds = obj.sel("select tblPropertyMaster.PropertyId, tblPropertyTypeMaster.PropertyTypeName, tblSubPropertyTypeMaster.PropertySubTypeName, tblPropertyMaster.Floor, tblPropertyMaster.PlotArea, tblPropertyMaster.BuitUpArea, tblPropertyMaster.ExpectedAmount, tblCityMaster.CityName, tblLocationMaster.LocationName, tblBuilderMaster.BuilderName, tblPropertyMaster.Description, tblPropertyMaster.Remarks, tblPropertyMaster.Furniture AS Furntr, tblPropertyMaster.IsAdvertise, tblPropertyMaster.Status, tblPropertyMaster.OwnerName, tblPropertyMaster.Address, tblPropertyMaster.ContactNo, tblPropertyMaster.MobileNo, tblPropertyMaster.EmailId from tblPropertyMaster INNER JOIN tblPropertyTypeMaster ON tblPropertyMaster.PropertyTypeId=tblPropertyTypeMaster.PropertyTypeId INNER JOIN tblSubPropertyTypeMaster ON tblPropertyMaster.PropertySubTypeId=tblSubPropertyTypeMaster.PropertySubTypeId INNER JOIN tblCityMaster ON tblPropertyMaster.CityId=tblCityMaster.CityId INNER JOIN tblLocationMaster ON tblPropertyMaster.LocationId=tblLocationMaster.LocationId INNER JOIN tblBuilderMaster ON tblPropertyMaster.BuilderName=tblBuilderMaster.BuilderId where tblPropertyMaster.PropertyId= '" + id + "'");
string furn = ds.Tables[0].Rows[0]["Furntr"].ToString();
if (furn == "True")
{
rbBRPFetchFurnitureYesC.Checked = true;
}
if (furn == "False")
{
rbBRPFetchFurnitureNoC.Checked = true;
}
string stts = ds.Tables[0].Rows[0]["Status"].ToString();
if (stts == "True")
{
rbBRPFetchStatusSoldC.Checked = true;
}
if (stts == "False")
{
rbBRPFetchStatusNtSoldC.Checked = true;
}
string advrts = ds.Tables[0].Rows[0]["IsAdvertise"].ToString();
if (advrts == "True")
{
rbBRPFetchIsAdYesC.Checked = true;
}
if (advrts == "False")
{
rbBRPFetchIsAdNoC.Checked = true;
}
ddlBRPFetchTypOfPrptC.SelectedItem.Text = ds.Tables[0].Rows[0]["PropertyTypeName"].ToString();
ddlBRPFetchSbTypOfPrptC.SelectedItem.Text = ds.Tables[0].Rows[0]["PropertySubTypeName"].ToString();
txtBRPFetchFloorC.Text = ds.Tables[0].Rows[0]["Floor"].ToString();
txtBRPFetchPlotAreaC.Text = ds.Tables[0].Rows[0]["PlotArea"].ToString();
txtBRPFetchBiultUpAreaC.Text = ds.Tables[0].Rows[0]["BuitUpArea"].ToString();
txtBRPFetchAmountC.Text = ds.Tables[0].Rows[0]["ExpectedAmount"].ToString();
ddlBRPFetchCityC.SelectedItem.Text = ds.Tables[0].Rows[0]["CityName"].ToString();
ddlBRPFetchLocationC.SelectedItem.Text = ds.Tables[0].Rows[0]["LocationName"].ToString();
ddlBRPFetchBuilderNameC.SelectedItem.Text = ds.Tables[0].Rows[0]["BuilderName"].ToString();
txtBRPFetchDescC.Text = ds.Tables[0].Rows[0]["Description"].ToString();
txtBRPFetchRemrksC.Text = ds.Tables[0].Rows[0]["Remarks"].ToString();
txtBRPFetchOwnerNameC.Text = ds.Tables[0].Rows[0]["OwnerName"].ToString();
txtBRPFetchAddressC.Text = ds.Tables[0].Rows[0]["Address"].ToString();
txtBRPFetchConNumberC.Text = ds.Tables[0].Rows[0]["ContactNo"].ToString();
txtBRPFetchMobNumberC.Text = ds.Tables[0].Rows[0]["MobileNo"].ToString();
txtBRPFetchEmailC.Text = ds.Tables[0].Rows[0]["EmailId"].ToString();
pnlBRPUpdateBySessionCriteria.Visible = true;
pnlSearchBRPByDate.Visible = false;
pnlBRPManageGrid.Visible = false;
}
As a precautionary step always first check Rows are present and then only extract values from rows.
if(ds.Tables[0].Rows.Count > 0)
{
// Your code
}

delete related data from a single table

hi I have table with id usertypeId, managerId, SupervisorId n representative id..
when perticuler user login..
suppose manager then it will display the data related to manager..
when we want to delete the data then login user will not be deleted but when suppose superviosr is deleted then its related data like
reperesentative shoulb be delete..
here is my code:
if (Session["UserTypeId"].ToString() == "2")
{
DataTable dt1 = new BALUserProfile().SelectForGridManager(
new BOLUserProfile() { Id = int.Parse(Session["UserId"].ToString()),
ManagerId = int.Parse(Session["UserId"].ToString()) });
for (int i = 0; i < dt1.Rows.Count; i++)
{
if (dt1.Rows[i]["Id"].ToString() == Session["UserId"].ToString() &&
lblGUserTypeId1.ToString() == "2")
{
lblMessageGrid.Visible = true;
lblMessageGrid.Text = "Data Can Not Be Delete";
}
else
{
//ObjBOL.Id = int.Parse(dt1.Rows[i]["Id"].ToString());
//ObjBOL1.Id = int.Parse(dt1.Rows[i]["Id"].ToString());
ObjBAL.Delete(ObjBOL);
ObjBAL1.Delete(ObjBOL1);
}
}
} //this was missing
ya i know that but thanks...

Extjs4 multigrouping header value css

I am using the Extjs4 multigrouping plugin from here.
I have used it successfully, however i want to show the summary of the totals of each column within the group header itself . how do i set up the appropriate CSS for that ?
In Multigrouping.js
getFragmentTpl: function() {
var me = this;
return {
indentByDepth: me.indentByDepth,
depthToIndent: me.depthToIndent,
renderGroupHeaderTpl: function(values, parent) {
return Ext.XTemplate.getTpl(me, 'groupHeaderTpl').apply(values, parent);
//var z = new Ext.XTemplate('{name} ({rows.grouplength})');
//return z.apply(values, parent);
}
};
},
In my grid
features: [
{
ftype:'multigrouping',
groupHeaderTpl: [
'{[this.readOut(values)]}',
{
readOut:function(values) {
debugger;
var sum1 =0 ,sum2=0,sum3=0;
for( var i = 0 ; i< values.records.length ; i++)
{
var val = parseFloat(values.records[i].data.d2012.mp);
sum1 += isNaN(val) ? 0.0 : val;
val = parseFloat(values.records[i].data.d2013.mp);
sum2 += isNaN(val) ? 0.0 : val;
val = parseFloat(values.records[i].data.d2014.mp);
sum3 += isNaN(val) ? 0.0 : val;
}
return values.name + '(' + values.records.length + ')' + ' ' + sum1.toFixed(2) + ' ' + sum2.toFixed(2) + ' ' + sum3.toFixed(2);
}
}
]
},
had to resort to a few hacks to get this to work. still waiting on an official answer.
The main reason i had to do this and not use the multigrouping summary is because
- i want to limit the number of records from the server. I can do some smart grouping of
my business objects at the server side.
- the main reason to do this is because of IE8's performance on larger sets of data.
- had already tried the extjs4 tree grid component which works well on chrome but had performance issues on IE8.
the hack is to
a) use an array property in the grid to store the dom elements which i want to manipulate
b) use a boolean to know when the layout is completed the first time
b) add listeners for afterlayout ( when your app can do an Ext.get('..dom element..') you know you are done )
The listener :
listeners :
{
afterlayout : function(eopts)
{
var x = this.mOwnArray;
if(!this.loadedwithVals && x.length > 0)
{
for(var i =0 ; i<x.length ; i++)
{
var dom = Ext.get(x[i].id);
var theId = dom.id;
theId = theId.match(/\d+/)[0];
var title = dom.query("td[class='x-grid-cell x-grid-cell-first']");
title[0].className = 'x-grid-cell x-grid-cell-gridcolumn-' + theId + ' x-grid-cell-first';
title[0].colSpan=1;
var groupedHeader = dom.query("div[class='x-grid-group-title']");
groupedHeader[0].innerHTML = x[i].name + '(' + x[i].length + ')';
for(var year=2012;year<=2018;year++)
{
var t = "t"+year;
var someText1 = '<td class=" x-grid-cell x-grid-cell-numbercolumn">';
var someText2 = '<div class="x-grid-cell-inner " style="text-align: left; ;">';
var someText3 = '<div class="x-grid-group-title">' + x[i].total[t] + '</div></div></td>';
var someText = someText1 + someText2 + someText3;
dom.insertHtml("beforeEnd",someText);
}
}
this.loadedwithVals = true;
}
}
And the feature as in
features: [
{
ftype:'multigrouping',
startCollapsed : true,
groupHeaderTpl: [
'{[this.readOut(values)]}',
{
readOut:function(values) {
var header = new Object();
header.id = values.groupHeaderId;
header.sum = [];
header.total = new Object();
for(var year = 2012 ; year <= 2018 ; year++)
{
var t = "t"+year;
header.total[t] = [];
}
// all the records in this header
for( var i = 0 ; i< values.records.length ; i++)
{
// for all the 'years' in this record
for(var year=2012;year<=2018;year++)
{
var d = "d"+year;
var ct = "t" + year;
var arecord = values.records[i].data;
var val = parseFloat(arecord[d].mp);
val = isNaN(val) ? 0.0 : val;
Ext.Array.push(header.total[ct],val);
}
}
// push the sum of the records into its top level group
for(var year = 2012 ; year <= 2018 ; year++)
{
var t = "t"+year;
var sum = Ext.Array.sum(header.total[t]);
header.total[t] = sum.toFixed(2);
}
header.name = values.name;
header.length = values.records.length;
var headerName = values.name;
if(values.hasOwnProperty('parent'))
{
var parent = values.parent;
headerName = headerName.replace(parent,'');
}
header.name = headerName;
header.length = values.records.length;
Ext.Array.push(grid.mOwnArray,header);
// really not used
return values.name + '(' + values.records.length + ')';
}
}
]
},
]

Resources