Programatic control using Telerik OpenAccess ORM and the RadGrid - telerik-grid

Ok, between following documentation, posts and videos that use syntax and tools that are no longer used or available, I'm really lost as to how to go about even using Telerik's OpenAccess. So I thought I'd ask for some help and hopefully someone out there has done this before.
I want to simply bind my OpenAccess entities to a RadGrid, but I want to use TemplateColumn in my RadGrid (in editmode, I want to use other controls like datepickers, dropdowns, etc.) Therefore, like the old way of doing things, I want to fire off the RadGrid's ItemDataBound event, for example, find the controls and set the controls to the appropriate values.
Old way that we were used to (You know, like the old fashioned way of something like setting a RadTextBox to a value from the RadGrid's DataSource, which was a DataReader:):
string strID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["campaignID"].ToString();
RadTextBox rtxtTitle = (RadTextBox)e.Item.FindControl("rtxtTitle");
rtxtTitle.Text = DataBinder.Eval(e.Item.DataItem, "title").ToString();
Does anyone have sample out there of how to do this? I would assume that I would also need to know how to bind the RadGrid in the first place, so an example of that would also be helpful (NOT using the actual OpenAccessDataSource control - I want to bind it in the NeedDataSource event of the RadGrid).
Thanks in advance...

The sample I found on the Telerik web site for DataBinding an OpenAccess result to a DataGrid looks like this:
IObjectScope scope = ScopeFactory.GetScope(HttpContext.Current);
string query = String.Format("SELECT * FROM {0}Extent", viewName);
IQueryResult result = scope.GetOqlQuery(query).Execute();
RadGrid1.DataSource = result.ToList();
This looks to be using OQL, but you could also use LINQ. I would toss this question to the OpenAccess team on the forums. They can probably point you to better resources.

Related

Best way to implement ACL with Mongoose

I have my data model already defined and implemented. I can very easily write manually the filter to filter out non-authorized results for the user who sent the query (which would be in the style of: "collection.acl.personId": queryPersonId )
My problem is, where and how should I write this "thing" to be as automatic as possible?
I tried to do it with a custom query and a static method, but did not had any luck on both.
Static method con: I don't want to rewrite all my code to use .then(). I want to keep the current chaining.
Custom query: it simply did not worked, even by following the doc.
Ideal the result would be something like
Model.findWithAcl(filters).lean()
Model.findOneWithAcl(filters).lean()
Note that we are using Typescript. The priority would be to have something working, but having the ability to have a working type would be the second priority right after.
Thanks for any help
Casl mongoose gives a very good way of filtering both results (row level) and fields from collections. Note that it also can be used in the front end.
Great package that works very well with auth0 rights.
https://casl.js.org/v5/en/guide/intro
https://casl.js.org/v5/en/package/casl-mongoose

CRM365 - Views with complex column layout

The current CRM UI allows you to create relatively complex queries which you can even extend further with tools like FetchXML Builder.
However, when we get to select the columns in the View layout, the interface provides access only to the first direct related set of entities and does not navigate further down.
There are many cases where the column you want to include in the View is just "two-clicks" away and you cannot include it because is "too far". To make things worse, the FetchXML Builder allows you to re-write the join but it does not allow you change the the columns layout you started with when you opened the View initially. IOW, you can modify the query logic but you cannot include additional columns as required.
One possible solution would be to edit the solution directly and inject the FetchXML directly (I have not tried this though) but I would like to listen to the community opinion first or to other possible solution.
Regards and thank you for taking your time.
Unfortunately this is a long existing limitation. There is no supported customization workaround to circumvent this other than building a Fetchxml report or Power BI report to embed with the necessary layout.
From documentation:
You can include columns from the current entity or any of the related entities that have a 1:N entity relationship with the current entity.
You can tweak the layoutxml of any view, but still it has to be in supported zone to avoid failures.

Tabulator - exclusive header filters - how?

I wrote and support a little web app for our local animal shelter to help volunteers locate dogs. I chose Tabulator because it had great features and was easy to use and have been very happy with my choice. For the first version of the app I used external input fields to search and manually did all the wiring to support live search.
Now I am working on v2 and am trying to use header filters. My problem is that the filters need to be exclusive, that is, using filter1 clears/disables filters 2 and 3, using filter2 clears/disables 1 and 3, and so on. With the external search fields I used focus() events to do this. When I try using jQuery on(focus) delegates to do the same with header filters and for example table.setHeaderFilterValue("field1", "") it does not work; the event triggers but the input box never gets the focus so I cannot type in it. I've tried different events like click; but nothing I've tried works properly.
I've studied the docs and struggled with this for several hours. I've considered hooking dataFiltering() and eliminating the filters I don't want, but I'm not sure how to identify the filter that I want to keep, and there is still the matter of the text in the fields to be dealt with. I'm sure it doesn't help that front-end work is not my area of expertise, though so far I've managed well enough. Is there a simple or normal way to do this that I'm just not seeing?
For the record, I found a way to do exclusive filtering with header filters with a single event callback:
\$(document).on("focus", ".tabulator-col input[type=search]", function() {
var hfNames = ["name", "anum", "kennel"];
var fieldName = \$(this).closest(".tabulator-col")[0].getAttribute("tabulator-field");
hfNames.map(function(hfN) { if (hfN != fieldName) table.setHeaderFilterValue(hfN, "") });
});
The three hfNames are the field names of the columns with filtering on. Yes, I could have derived them dynamically, but it didn't seem worth it for a small app like this.
As I suspected, the key was simply a better knowledge of JQuery.

Xpage dynamic Id for data update or validation(CSJS)

Before describing the problem, I would like to add that I have looked for this problem on google and have found many solutions but none related to XPAGES. Since, Xpage have a unique method to generate the field id I am facing this problem. I have also posted the same question here on IBM forum and awaiting the reply there(http://www-10.lotus.com/ldd/ndseforum.nsf/xpTopicThread.xsp?documentId=EDEBB14BDF2E804F85257BE8001E4F76):
Problem:
I am trying to pass dynamic id to the default function getElementById with no success. To explain it clearly, I have a front end validation for specific fields. This fields are stored n database. So, I have a for loop running for all the fields. The problem here is that XPages generates the Id dynamically and hence for the same form if there is a hierarchical tabbed panel then the Id also included the tabbed panel Id in it.
Here is the code view of the problem:
The standard method to retrieve the value(CSJS) is:
document.getElementById("#{id:inputText1}").value;
However, if I try to pass in a dynamic id. It doesn't work. I have tried "n" number of approaches I found on Google but none regarding this problem. One solution I tried here was:
var x = "inputText1";
document.getElementById("#{id:"+x+"}").value;
Any help would really be appreciated. Really eager to hear some good suggestion.
The "#{id:inputText1}" part is computed at the server before the page is served so it's too late to set the ID in client side JS.
To set the ID in SSJS you can do this:
document.getElementById("#{javascript:var x='inputText1'; getClientId(x)}").value;
With getClientId you can also build a CSJS array of IDs in in SSJS. Then you can loop that array in CSJS. You would build the array this way:
var strIDs = ${javascript:'["a","b","c"]'};

Query and/or Search for SharePoint Document ID

We have the sharepoint 2010 environment with Document ID's enabled.
Given (part of) a Doc ID, we want to programmatically retrieve the document(s) matching that ID. The problem seems to be that this column is rather special, in that it might need special handling.
Using an SPSiteDataQuery, fetching the _dlc_DocId field as part of the viewfields works fine. However, including it as part of the where query never results in any documents being fetched.
Using the Search API has gotten us nowhere at all.
Has anyone pulled this off, or any suggestions on how to tackle this problem?
[Update] Turns out we were fooled by subtle errors in the XML and bad debugging misinterpretations. This stuff just works fine.
I don't normally contribute to these sorts of things because cleverer people than I always get there before me, but as this is an old one with no proper answer I think I'll add my thoughts for those who find this page.
I was struggling with this but after a little digging around and learning a bit of Caml I got this working.
I am using the SharePoint Client Object Model against SharePoint 2010 and Office365 beta.
Start off your query by looking at the all list items query:
Microsoft.SharePoint.Client.CamlQuery.CreateAllItemsQuery().ViewXml
"<View Scope=\"RecursiveAll\">\r\n <Query>\r\n </Query>\r\n</View>"
Stick a where child inside the query
Then add in
<Eq><FieldRef Name="_dlc_DocId" /><Value Type="Text">MDXC2KE55ASN-3-80</Value></Eq>
replacing MDXC2KE55ASN-3-80 with the doc ID you are looking for inside the where.
Also don't forget you might want to make use of these too:
<ViewFields><FieldRef Name="_dlc_DocId" /></ViewFields>
<RowLimit>1</RowLimit>
Then use List.GetItems() method to bring back the ListItemCollection.
Just in case nobody comes with a slick solutions from the depths of the Sharepoint infrastructure:
What would Google Do?
Slice is, Dice it and dump it in a reverse index.
Solr and Lucene offer supreme tools for this. The idea is to cut the DocId's in small pieces and add the location of the document to the bucket for that piece.
Say We have "A real nice document" with Id ABCD123. You would add it to the buckets
ABCD, BCD1, CD12, D123
When searching for a partial ID (+ other data like dates, types, ...) you (well the search engine) creates the union of the buckets + applies additonal constraints.
To make this happen you need to write a spider for the sharepoint server and a routine which makes a record of data elements to be indexed.
Put a nice REST interface in frnt of it (actually SOLR already has that), integrate it in the main sharepoint server, and nobody needs to know there is something else running behind it.
These products can also incrementally update the indexes, so they can be kept up to date.
you could use the following to get the Document ID.
SPFile file = MethodToUploadFileToServer(web, filepath);
SPListItem item = file.Item;
string DocID = item.Properties["_dlc_DocId"].ToString();

Resources