Telerik Load on demand RadOrgChart not loading nodes after 3 levels - asp.net

In Telerik Load on demand RadOrgChart, I'm Loading data through server.
It will take up to 2 levels of data on every time click of each node. but data is coming properly from server,but problem is nodes not generated for those data. what should I do to get it properly?
private void CreateTeams() {
teams = new DataTable();
teams.Columns.Add("UniqueID");
teams.Columns.Add("ReportsTo");
teams.Columns.Add("Collapsed");
var myList = (List < NodeViewModel > ) Session["items"];
foreach(var nodeitem in myList) {
if (nodeitem.IsManager == true && nodeitem.level == 0) {
teams.Rows.Add(new string[] {
nodeitem.EmployeeBadge, null, "0"
});
} else {
teams.Rows.Add(new string[] {
nodeitem.EmployeeBadge, nodeitem.ManagerBadge, "1"
});
}
}
}
protected void Page_Load(object sender, EventArgs e) {
if (Request.Cookies["badgeName"] != null) {
var value = Request.Cookies["badgeName"].Value;
EmployeeRepository obj = new EmployeeRepository();
var myList = (List < NodeViewModel > ) Session["items"];
try {
obj.CreateLevel(new NodeViewModel() {
EmployeeBadge = value
}, myList);
logger.Info("OrgChart:Page_Load()::success");
} catch (Exception ex) {
logger.Error(string.Concat("OrgChart:Page_Load()::", ex.Message));
logger.Error(string.Concat("OrgChart:Page_Load()::", ex.StackTrace));
}
Response.Cookies["badgeName"].Expires = DateTime.Now.AddDays(-1);
}
CreateTeams();
CreateEmployees();
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataFieldID = "UniqueID";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataFieldParentID = "ReportsTo";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataCollapsedField = "Collapsed";
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataGroupCollapsedField = "Collapsed";
//RadOrgChart1.RenderedFields.NodeFields.Add(new Telerik.Web.UI.OrgChartRenderedField() { DataField = "Team" });
RadOrgChart1.GroupEnabledBinding.NodeBindingSettings.DataSource = teams;
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataFieldID = "EmployeeID";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataFieldNodeID = "UniqueID";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataTextField = "Name";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataImageUrlField = "ImageUrl";
RadOrgChart1.GroupEnabledBinding.GroupItemBindingSettings.DataSource = employees;
RadOrgChart1.DataBind();
}

Related

Xamarin forms: How to add tapped event on XamForms.Controls.Calendar specialdate?

I am using XamForms.Controls.Calendar package for showing calendar in my project. I am marking events on the calendar using the below code.
private void AddSpecialDateWithList(List<events> list)
{
List<SpecialDate> newList = new List<SpecialDate>();
foreach (events model in list)
{
string startDate = model.start;
int startIndex = startDate.IndexOf('T');
if (startIndex > 0)
{
startDate = startDate.Substring(0, startIndex);
}
string endDate = model.end;
int endIndex = endDate.IndexOf('T');
if (endIndex > 0)
{
endDate = endDate.Substring(0, endIndex);
}
List<DateTime> dates = GetDatesBetween(DateTime.Parse(startDate), DateTime.Parse(endDate));
for(int i=0;i< dates.Count; i++)
{
var newDate = AddDate(dates[i], model);
newList.Add(newDate);
}
}
calendar.SpecialDates = newList;
}
private SpecialDate AddDate(DateTime dateTime, events model)
{
SpecialDate newDate = new SpecialDate(dateTime)
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern { WidthPercent = 1f, HightPercent = 0.7f, Color = Color.White },
new Pattern{ WidthPercent = 1f, HightPercent = 0.3f, Color = Color.Yellow, Text = model.title, TextColor=Color.Black, TextSize=10, TextAlign=TextAlign.LeftCenter},
}
}
};
return newDate;
}
Screenshot:
When I tap a day having event(31 Jan having maths homework), I need to get the event id and all the other details associated with that event. How can I do this feature? Also is it possible to show month, week and day view in XamForms.Controls.Calendar?
You could get the index of SpecialDate in your list in the event DateClicked
private void calendar_DateClicked(object sender, DateTimeEventArgs e)
{
int num = 0;
var specialList = calendar.SpecialDates;
var date = e.DateTime;
foreach(SpecialDate specialDate in specialList)
{
if(specialDate.Date.Year==date.Year&& specialDate.Date.Month == date.Month&&specialDate.Date.Day == date.Day)
{
events model = list[num];
// do something you want
}
else
{
num++;
}
}
}

customize the height and width of ESRI map callout

here is the formatted String which i am binding to callout but i am able to see only some contents of my string in callout
private async void WebMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
{
try
{
WebMapView.DismissCallout();
MapPoint mapLocation = null;
var layers = await WebMapView.IdentifyLayersAsync(e.Position, 20, false);
if (layers.Count > 0)
{
foreach (var idResults in layers)
{
FeatureLayer idLayer = idResults.LayerContent as FeatureLayer;
await idLayer.LoadAsync();
var result = layers.First();
var feature = result.GeoElements.First() as ArcGISFeature;
await feature.LoadAsync(); // Load feature to get all attributes
Feature idFeature = result.GeoElements.First() as Feature;
featureAttrs = idFeature.Attributes;
var stateExtent = idFeature.Geometry;
Graphicoverlay = new GraphicsOverlay();
Graphic graphicLine = null;
graphicLine = new Graphic(stateExtent, AppConstant.HighLight1);
Graphicoverlay.Graphics.Add(graphicLine);
EnvelopeBuilder myEnvelopeBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);
//Geometry abd = oneGraphic.Geometry;
myEnvelopeBuilder.UnionOf(graphicLine.Geometry.Extent);
myEnvelopeBuilder.Expand(1.3);
mapLocation = myEnvelopeBuilder.Center;
Geometry myGeometry = GeometryEngine.Project(mapLocation, SpatialReferences.WebMercator);
MapPoint projectedLocation = (MapPoint)myGeometry;
string formattedString = "";
if (featureAttrs.Count > 0)
{
foreach (var attributes in featureAttrs)
{
string recordOneAttribute = $"{attributes.Key} {attributes.Value}";
formattedString = $"{formattedString}\n{ recordOneAttribute}";
}
}
CalloutDefinition calloutDef = new CalloutDefinition("Feature:",formattedString);
WebMapView.ShowCalloutAt(mapLocation, calloutDef);
}
}

How to get gmail attachment into local device store with intent filter

In my application i want to open gmail attachment with my application, i used intent filter for that,
I am getting URI and i want to use that and copy that attachment to my local device and want to display that with my application .
url = {content://com.google.android.gm.sapi/abc#gmail.com/message_attachment_external/%23thread-f%3A1610966348228029097/%23msg-f%3A1610966348228029097/0.1?account_type=com.google&mimeType=application%2Foctet-stream&rendition=1}
After a days of research and implementation, Here is a final solution for gmail attachment file , to view and down load in our application.
[IntentFilter(new string[] { Intent.ActionView }, Categories = new string[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "content", DataMimeType = "application/octet-stream")]
Stream inputsTream = resolver.OpenInputStream(url);
fs = File.Create(fileName);
byte[] buffer = new byte[32768];
int count;
int offset = 0;
while ((count = inputsTream.Read(buffer, offset, buffer.Length)) > 0)
{
fs.Write(buffer, 0, count);
}
fs.Close();
inputsTream.Close();
private fun deepLinkAcceptor(){
var ins: InputStream? = null
var os: FileOutputStream? = null
var fullPath: String? = null
var file: File;
try {
val action = intent.action
if (Intent.ACTION_VIEW != action) {
return
}
val uri = intent.data
val scheme = uri!!.scheme
var name: String? = null
if (scheme == "content") {
val cursor = contentResolver.query(
uri!!, arrayOf(
MediaStore.MediaColumns.DISPLAY_NAME
), null, null, null
)
cursor!!.moveToFirst()
val nameIndex = cursor!!.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME)
if (nameIndex >= 0) {
name = cursor!!.getString(nameIndex)
}
} else {
return
}
if (name == null) {
return
}
val n = name.lastIndexOf(".")
val fileName: String
val fileExt: String
if (n == -1) {
return
} else {
fileName = name.substring(0, n)
fileExt = name.substring(n)
}
// create full path to where the file is to go, including name/ext
fullPath = ""
val filenm = fileName + fileExt
file = File(cacheDir, filenm)
ins = contentResolver.openInputStream(uri!!)
os = FileOutputStream(file.getPath())
val buffer = ByteArray(4096)
var count: Int
while (ins!!.read(buffer).also { count = it } > 0) {
os!!.write(buffer, 0, count)
}
os!!.close()
ins!!.close()
println("===onfile path: " + file.getAbsolutePath())
println("===onFile name: " + file.readText())
} catch (e: Exception) {
if (ins != null) {
try {
ins.close()
} catch (e1: Exception) {
}
}
if (os != null) {
try {
os.close()
} catch (e1: Exception) {
}
}
if (fullPath != null) {
val f = File(fullPath)
f.delete()
}
}
}

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;
}
}
}
}
}

Can't retrieve data entered in first empty row of grid view

I have placed grid view in update panel with first row as empty and it is not bound with any data base. Rather I have bound grid view with data table. Whenever I click on 'Add New Row' button, a new row is created in grid view there by retaining the data field in old rows but my problem is whenever I click on save button, at that time data of first row is not retried but I can get the data that is filled in second row and onwards. I have saved my data table in session and again retrieving it after each post back.
Here is the code of my .aspx.cs page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using AppResumeMaster;
using System.Collections;
using AppQualificationDetail;
public partial class Applicant_ApplicationForm : System.Web.UI.Page
{
int Rows = 1;
object MaxAppId = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
setInitialRow();
}
}
protected void saveBtn_Click(object sender, EventArgs e)
{
try
{
using (DataOperation oDo = new DataOperation())
{
MaxAppId= oDo.ExecuteScaler("select max(AppId) from tblAppResumeMaster");
if (MaxAppId == System.DBNull.Value)
MaxAppId = 0;
}
using (AppResumeMasterClass objAppResumeMasterClass = new AppResumeMasterClass())
{
objAppResumeMasterClass.AppId = Convert.ToInt32(MaxAppId)+1;
objAppResumeMasterClass.AppFirstName = firstnameBox.Text;
objAppResumeMasterClass.AppLastName = lastnameBox.Text;
objAppResumeMasterClass.AppAddress1 = CurAddBox.Text;
objAppResumeMasterClass.AppCity1 = CurAddBox.Text;
objAppResumeMasterClass.AppState1 = CurStateBox.Text;
objAppResumeMasterClass.AppCountry1 = CurCountrybox.Text;
objAppResumeMasterClass.AppAddress2 = PerAddBox.Text;
objAppResumeMasterClass.AppCity2 = PerCityBox.Text;
objAppResumeMasterClass.AppState2 = PerStateBox.Text;
objAppResumeMasterClass.AppCountry2 = PerCountrybox.Text;
objAppResumeMasterClass.AppEmail1 = emailBox.Text;
objAppResumeMasterClass.AppEmail2 = AltEmailBox.Text;
objAppResumeMasterClass.AppMobileNo = mobileNoBox.Text;
objAppResumeMasterClass.AppContactNo = phoneNoBox.Text;
objAppResumeMasterClass.AppDOB = Convert.ToDateTime(birthDateBox.Text);
objAppResumeMasterClass.AppKeySkill = skillsBox.Text;
objAppResumeMasterClass.AppGoal = goalBox.Text;
objAppResumeMasterClass.AppWeakness = weaknessBox.Text;
objAppResumeMasterClass.AppStrengths = strengthsBox.Text;
objAppResumeMasterClass.setVal(1);
}
DataTable Table = (DataTable)Session["CurTable"];
int cnt = Table.Rows.Count;
using(AppQualificationDetailClass objAppQualificationDetail = new AppQualificationDetailClass())
{
for (int RowCnt = 0; RowCnt < Table.Rows.Count; RowCnt++)
{
objAppQualificationDetail.AppId = Convert.ToInt32(MaxAppId) + 1;
objAppQualificationDetail.QualiId = Convert.ToInt32(Table.Rows[RowCnt][1]);
objAppQualificationDetail.Year = Convert.ToInt32(Table.Rows[RowCnt][3]);
objAppQualificationDetail.Percentage = (float)Table.Rows[RowCnt][2];
objAppQualificationDetail.InstiName = Table.Rows[RowCnt][4].ToString();
objAppQualificationDetail.setVal(1);
}
}
ExistMsgLbl.Text = Table.Rows[0][2].ToString();
}
catch (Exception ex)
{
throw ex;
}
}
protected void addRowBtn_Click(object sender, EventArgs e)
{
AddNewRow();
}
protected void InstituteLbl_PreRender(object sender, EventArgs e)
{
//Session.Add("Table", Table1);
}
public void setInitialRow()
{
DataTable Table = new DataTable();
DataRow dr = null;
Table.Columns.Add(new DataColumn("Qualification",typeof(string)));
Table.Columns.Add(new DataColumn("QualiId",typeof(string)));
Table.Columns.Add(new DataColumn("Percentage",typeof(string)));
Table.Columns.Add(new DataColumn("Passing Year",typeof(string)));
Table.Columns.Add(new DataColumn("Institute Name",typeof(string)));
dr = Table.NewRow();
dr["Percentage"] = string.Empty;
dr["Passing Year"] = string.Empty;
dr["Institute Name"]=string.Empty;
Table.Rows.Add(dr);
Session.Add("CurTable", Table);
GridView1.DataSource = Table;
GridView1.DataBind();
ArrayList Array = new ArrayList();
DataSet ds = new DataSet();
DropDownList DDL = (DropDownList)GridView1.Rows[0].Cells[0].FindControl("QualificationList");
FillDropDownList(DDL);
}
public void AddNewRow()
{
DataSet ds=new DataSet();
int RowIndex = 0;
if (Session["CurTable"] != null)
{
DataTable CurTable = (DataTable)Session["CurTable"];
DataRow CurRow = null;
if (CurTable.Rows.Count > 0)
{
CurRow = CurTable.NewRow();
CurTable.Rows.Add(CurRow);
Session.Add("CurTable", CurTable);
for (int count = 0; count < CurTable.Rows.Count - 1; count++)
{
DropDownList DDL = (DropDownList)GridView1.Rows[count].Cells[0].FindControl("QualificationList");
TextBox PercentageBox = (TextBox)GridView1.Rows[count].Cells[1].FindControl("percentageBox");
TextBox yearBox = (TextBox)GridView1.Rows[count].Cells[1].FindControl("yearBox");
TextBox InstituteNameBox = (TextBox)GridView1.Rows[count].Cells[1].FindControl("InstituteNameBox");
CurTable.Rows[count]["Percentage"] = PercentageBox.Text;
CurTable.Rows[count]["Passing Year"]=yearBox.Text;
CurTable.Rows[count]["Institute Name"]=InstituteNameBox.Text;
CurTable.Rows[count]["Qualification"]=DDL.SelectedItem.Text;
CurTable.Rows[count]["QualiId"] = DDL.SelectedValue;
}
GridView1.DataSource = CurTable;
GridView1.DataBind();
}
}
setPreviousData();
}
public void setPreviousData()
{
int RowIndex = 0;
if (Session["CurTable"] != null)
{
DataTable RestoreTable = (DataTable)Session["CurTable"];
if (RestoreTable.Rows.Count > 0)
{
for (int row = 0; row < RestoreTable.Rows.Count; row++)
{
DropDownList DPList = (DropDownList)GridView1.Rows[row].Cells[0].FindControl("QualificationList");
TextBox PercentageBox = (TextBox)GridView1.Rows[row].Cells[1].FindControl("percentageBox");
TextBox YearBox = (TextBox)GridView1.Rows[row].Cells[2].FindControl("yearBox");
TextBox InstituteName = (TextBox)GridView1.Rows[row].Cells[3].FindControl("InstituteNamebox");
FillDropDownList(DPList);
if (row < RestoreTable.Rows.Count - 1)
{
PercentageBox.Text = RestoreTable.Rows[row]["Percentage"].ToString();
YearBox.Text = RestoreTable.Rows[row]["Passing Year"].ToString();
InstituteName.Text = RestoreTable.Rows[row]["Institute Name"].ToString();
DPList.ClearSelection();
DPList.Items.FindByText(RestoreTable.Rows[row]["Qualification"].ToString()).Selected = true;
}
RowIndex++;
}
}
}
}
private ArrayList FillArrayList()
{
ArrayList ArrayList = new ArrayList();
DataSet ds = new DataSet();
using(DataOperation oDo = new DataOperation())
{
ds =oDo.DropDownList("select * from tblQualificationMaster");
for(int count=0;count<ds.Tables[0].Rows.Count;count++)
{
ArrayList.Add(new ListItem(ds.Tables[0].Rows[count][1].ToString(), ds.Tables[0].Rows[count][0].ToString()));
}
}
return ArrayList;
}
private void FillDropDownList(DropDownList DDL)
{
ArrayList ArrayList = FillArrayList();
foreach (ListItem item in ArrayList)
{
DDL.Items.Add(item);
}
}
}
Use ViewState instead of Session.

Resources