Send Data to Database on row click in jqgrid - jqgrid-asp.net

I want to send a single string "clicked" in to my database if i click a single row in jqgrid table. The database already contains a column for the string but i don't know how to send the string from jqgrid.
I can get the row and extract the primary key from the row with:
var myDebugTrace = function (startingText, rowid) {
var $this = $(this), p = $this.jqGrid("getGridParam"), rowData, col1,
firstCol = (p.rownumbers ? 1 : 0) + (p.subGrid ? 1 : 0);
rowData = $this.jqGrid("getRowData", rowid);
col1 = rowData[p.colModel[firstCol].name];
............
Than i just need a method in the code behind:
InsertIntoDatabase(id,"checked")

I found the solution. I had to use a .ashx Handler and post data with ajax:
$.ajax({ url:"MyHandler.ashx" ...

Related

Trying To Filter Only Rows That Meet Two Criteria

I promise I have read through the Query information page, but obviously I am missing/misunderstanding something.
I have a Table that has the statuses for multiple departments (the fields are Strings). When a user loads that table I want App Maker to hide jobs that have been finished.
The way we categorize a job as finishes is when:
The Inventory Status = Complete and when the The Delivery Status = Delivered.
Both these conditions need to be met.
Example:
Inventory (Complete) + Delivery (Delivered) = hide
Inventory (In Progress) + Delivery (Delivered) = don't hide
Inventory (Complete) + Delivery (Scheduled) = don't hide
I tried the following, however it hides all the example listed above, not just the first one.
var datasource = app.datasources.SystemOrders;
var inventory = ['Complete'];
var delivery = ['Delivered'];
datasource.query.filters.InventoryStatus._notIn = inventory;
datasource.query.filters.DeliveryStatus._notIn = delivery;
datasource.load();
I have also tried this:
var datasource = app.datasources.SystemOrders;
datasource.query.filters.InventoryStatus._notIn = 'Complete';
datasource.query.filters.DeliveryStatus._notIn = 'Delivered';
datasource.load();
But I get this error:
Type mismatch: Cannot set type String for property _notIn. Type List is expected. at SystemOrders.ToolBar.Button2.onClick:2:46
Any help would be greatly appreciated.
Filters are using AND operator. Please consider switching the Datasource Query Builder and applying the following query:
"InventoryStatus != :CompleteStatus OR DeliveryStatus != :DeliveredStatus"
Set CompleteStatus variable to Complete
Set DeliveredStatus variable to Delivered
Explanation:
Filter you want to apply is "NOT(InventoryStatus = Complete AND DeliveryStatus = Delivered)" which is equivalent to "InventoryStatus != Complete OR DeliveryStatus != Delivered".
Vasyl answer my question perfectly, but I wanted to add a few details in case anyone needs to do the same thing and aren't familiar with using the Datasource Query Builder.
All I did was click the Database I was using and then clicked the Datasources section at the top.
I clicked Add Datasource, named it a new name and pasted Vasyl's code into the Query Builder Expression box.
Two new boxes appear below it allowing me to enter the desired statuses that I wanted to filter out.
Lastly I went back to my Table and changed its datasource to my newly created datasource.
Since you are changing your datasource, if you have any extra code on there it may need to be updated to point to the new datasource.
Example:
I had some buttons that would filter entries for the various departments.
So this:
widget.datasource.query.clearFilters();
var datasource = app.datasources.SystemOrders;
var statuses = ['Complete'];
datasource.query.filters.WarehouseStatus._notIn = statuses;
datasource.load();
had to change to this:
widget.datasource.query.clearFilters();
var datasource = app.datasources.SystemOrders_HideComplete;
var statuses = ['Complete'];
datasource.query.filters.WarehouseStatus._notIn = statuses;
datasource.load();
You can use multiple run and then concatenate their results something like following
/**
* Retrieves records for ActionItems datasource.
* #param {RecordQuery} query - query object of the datasource;
* #return {Array<ActionItems>} user's rating as an array.
*/
function getActionItemsForUser_(query) {
var userRoles = app.getActiveUserRoles();
query.filters.Owner._contains = Session.getActiveUser().getEmail();
var ownerRecords = query.run();
query.clearFilters();
query.filters.AddedBy._contains = Session.getActiveUser().getEmail();
var addedByRecords = query.run();
return addedByRecords.concat(ownerRecords);
}

how to update a Google calendar event from asp application?

i want to insert a primary key of event to Google calendar and then retrieve it after EventQuery call to update that event
i didn't find any property in Evententry class to assign primary key and later to retrieve for updating that event.
It can be done by using ExtendedProperty using the approach below
1.Assign an ID (same as you set in your DB) to each event you add through
ExtendedProperty .
2.When updating / deleting you pass the ID and use Query to fetch it for you
3.If the event is found you can delete / update the specific event
Google.GData.Calendar.EventEntry Entry = new Google.GData.Calendar.EventEntry();
//create the ExtendedProperty and add the EventID in the new event object,
//so it can be deleted / updated later
ExtendedProperty oExtendedProperty = new ExtendedProperty();
oExtendedProperty.Name = "EventID";
oExtendedProperty.Value = GoogleAppointmentObj.EventID;
Entry.ExtensionElements.Add(oExtendedProperty);
string ThisFeedUri = "http://www.google.com/calendar/feeds/" + CalendarID
+ "/private/full";
Uri postUri = new Uri(ThisFeedUri);
//create an event query object and attach the EventID to it in Extraparameters
EventQuery Query = new EventQuery(ThisFeedUri);
Query.ExtraParameters = "extq=[EventID:" + GoogleAppointmentObj.EventID + "]";
Query.Uri = postUri;
//Find the event with the specific ID
EventFeed calFeed = CalService.Query(Query);
//if search contains result then delete
if (calFeed != null && calFeed.Entries.Count > 0)
{
foreach (EventEntry SearchedEntry in calFeed.Entries)
{
SearchedEntry.Delete();
//To update comment the code above and uncomment the code below
//CalService.Update(SearchedEntry);
break;
}
}
else
{
InsertedEntry = CalService.Insert(postUri, Entry);
}

ASP.NET C# Filter Data from Soap Service

I have a Soap service that I added to my .NET project via Service Reference.
problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
if (!IsPostBack)
{
rbProblemList.DataSource = getDescList;
rbProblemList.DataTextField = "description";
rbProblemList.DataValueField = "code";
rbProblemList.DataBind();
}
This returns a DropDownList of 23 items. (This list could grow in the future.) The service is returning an array of objects, where each object contains Category, Code, and Description.
How can I create a separate method that will return ONLY the 4 categories that exists in this array? I am unable to find any examples of how to create a method that will filter the data from a soap service.
Thank you in advance for any assistance.
This is basically the same code from another question you asked:
ASP.NET C# Filter DropDownList based on specific Category of Items from Soap Service
problemReporting.soapClient s = new problemReporting.soapClient();
problemReporting.NullRequest nr = new NullRequest();
problemReporting.ProblemDescription[] getDescList = s.getProblemDescriptionList(nr);
List<string> categories = new List<string>();
categories.Add("Category1");
categories.Add("Category2");
categories.Add("Category3");
var filteredResults = FilterCategories(categories, getDescList);
if (!IsPostBack)
{
rbProblemList.DataSource = filteredResults;
rbProblemList.DataTextField = "description";
rbProblemList.DataValueField = "code";
rbProblemList.DataBind();
}
public ProblemDescription[] FilterCategories(List<string> categories, ProblemDescription[] data )
{
var cats = from desc in data
where categories.Contains(desc.category)
select desc;
return cats;
}

Get value from jQuery in asp.net code nugget?

How can I get the value from a select field (dropdownlist) into a "code nugget" using jQuery? I have seen this done, but can't find an example of it now.
I have two dropdownlists, and I want to get the selected values from them and concatenate it into an id parameter to send to an action method:
$.get('<%= Url.Action("GetTasks","Timesheet", new { id = [Concatenated value here] } %>'
How can I get the concatenated selected values from the two dropdownlists with jQuery?
You could try something like this:
var url = "<% Url.Action("GetTasks", "Timesheet", new { id = "{0}" }) %>";
var selected = $("#mySelect").val().join(",");
url = url.replace("{0}", selected);
$.get(url);

Adobe Flex Salesforce problem converting account ids to account name

I am using Adobe Air to get data from SalesForce, and present it in a datagrid.
I am using a query to get the data, and then put it into an arraycollection that is bound to the datagrid, this works correctly and the data is displayed.
The problem is that I want to convert the Account Id in the Event to show the account Name. To do this I am using the following code:-
_serviceWrapper.query( "Select * From Event order by StartDateTime asc", new mx.rpc.Responder( eventQueryHandler, faultHandler ))}
protected function eventQueryHandler(qr:ArrayCollection):void {
var acctIdss:String = "";
for each(var contact:DynamicEntity in qr) {
if (contact.AccountId != null && acctIdss.indexOf(contact.AccountId) == -1) {
acctIdss += "'" + contact.AccountId + "',";
}
//contact.AccountName = ""; // Add field to contact for account name
TempGridProvider.addItem(contact); // Add contact to temp grid data data provider
//TempGridProvider.contact.AccountName = "";
}
acctIdss = acctIdss.substr(0, acctIdss.length - 1);
// Query for the accounts based on the account ids found in the contact list
_serviceWrapper.query("Select Id, Name, BillingCity From Account Where Id in (" + acctIdss + ")",
new SfdcAsyncResponder(Event2QueryHandler, faultHandler));
}
protected function Event2QueryHandler(accounts:ArrayCollection):void {
for each (var account:DynamicEntity in accounts) {
for each(var contact:DynamicEntity in TempGridProvider) {
if (contact.AccountId == account.Id) {
contact.AccountName = account.Name + " - " + account.BillingCity;
}
}
}
onQueryResult(TempGridProvider);
private function onQueryResult( rows : ArrayCollection ) : void {
// release previous query results
_serviceWrapper.releaseQueryResults( _gridDataProvider );
// populate datagrid
_gridDataProvider = rows;
// show message in status bar
var status : F3Message = new F3Message( F3Message.STATUS_INFO, "Query came back with " + ( _gridDataProvider == null ? 0 : _gridDataProvider.length ) + " " + _selectedEntity + "s" );
showStatus( status );
TempGridProvider = new ArrayCollection();;
}
This works and displays the Account Name, the problem is that when I use this script and then Sync Changes to SalesForce all the records that have been displayed are identified as needing to be syncronised even if they have only been displayed.
If I skip the function eventQueryHandler, and link my query to the OnQueryResult function then there is no problem, but only the Account Id can be displayed.
How can I stop Air marking these records as having changed, or is there a better way to achieve this??
Thanks in advance, any help is greatly appreciated.
Roy
I think you need to not manipulate the underlying object. There are two options for getting the data to render in a DataGrid.
Option 1 - Create another non-managed ValueObject that holds the values you need to display in the DataGrid. Copy the values when you receive them into the new ValueObject.
Option 2 - Use a labelFunction on the DataGridColumn to fetch the data externally when each cell in a given column is rendered.

Resources