jamii Archives: jQuery na SharePoint

Haraka Tip: Kuongeza jQuery kwa Moss Makala Publishing

Wakati kuimarisha Moss kurasa publising kutumia jQuery, I hit zifuatazo kasi mapema:

Server Error in ‘/’ Maombi.


Parser Hitilafu

Description: Hitilafu imetokea wakati parsing ya rasilimali zinazohitajika kwa huduma ya ombi hili. Tafadhali hakiki zifuatazo maalum maelezo kosa Hazrat na kurekebisha chanzo yako faili ipasavyo.

Parser Hitilafu Ujumbe: Udhibiti Content tu wanaruhusiwa moja kwa moja katika ukurasa maudhui ambayo ina udhibiti Content.

Chanzo Hitilafu:

 
Line 10: 
Line 11: 
Line 12: <script 
Line 13:     type="text/javascript" 
Line 14:     src="/jQuery/jquery-1.4.min.js"> 

Chanzo Picha: /_catalogs / masterpage / KCC_FacultyMember.aspx    Line: 12


Toleo Habari: Microsoft NET. Mkakati Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927

Ilikuwa rahisi kutosha kurekebisha (h / t mwenzangu, Uday Ethirajulu).  Kuwa na uhakika kwamba kanuni jQuery anaishi ndani "PlaceHolderAdditionalPageHead" kama inavyoonekana:

<ASP:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server">

<script

    type="text/javascript"

    src="/jQuery/jquery-1.4.min.js">

</script>

<script type="text/javascript">

  $(hati).tayari(kazi() {

   // Kipaji jQuery mambo huenda hapa.

   });

</script>

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Katika Sifa ya jQuery Enhanced Search-Kama Aina ya-Wewe- (na Jan Tielens)

Nafanya kazi demo BPOS (hivi karibuni kuwa inapatikana kwenye tovuti ya Microsoft) and I wanted to add a little pizzazz. I’ve known about Jan Tielen ya juhudi kwa muda kabisa na mimi walidhani itakuwa mbinu kubwa na kuongeza demo, so I did. You can read about it here: http://weblogs.asp.net/jan/archive/2009/07/02/sharepoint-search-as-you-type-with-jquery.aspx. It’s so simple to use it should probably be a crime (na labda ni mahali fulani).

Mimi kuongeza pointi mbili tu kwa kile tayari kuundwa / aliandika kuhusu:

  1. Hii haina, kwa kweli, kazi katika BPOs (SharePoint online) mazingira.
  2. Kufanya kazi yake bila ujumbe annoying popup kiambishi kumbukumbu ya maktaba na jQuery https badala ya http, kama katika:
<script aina ="text/javascript" src ="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

Jan points out that you should probably move the library itself to your site. Feeling a little lazy today, I decided to blog about it instead 🙂

</mwisho>

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Tags technorati:

Kupata SharePoint Views Library Orodha / Document Inaonekana (aina ya) Ikiwezekana na jQuery

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

Moja ya mambo ya kwanza nilidhani, mara moja Nilianza kucheza karibu na jQuery, was whether we could use it to secure a SharePoint view. The answer is “no” (au angalau, Mimi si wakidai inawezekana). Hata hivyo, it is certainly possible to make it difficult for people to see a particular view.

I started with my sandbox environment when working on this. I wrote about that environment here: Haraka na Easy: Kujenga jQuery yako mwenyewe Sandbox kwa SharePoint.

Na "kupata" maoni, kufuata hatua hizi:

  1. Create a view you want to secure. I did that and called it “Secured View”.

    Hii ni nini inaonekana kama wakati ni si "kuulinda":

    image

  2. Kuongeza mhariri maudhui ya mtandao sehemu ya ukurasa mtazamo wa kutumia hila ilivyoelezwa katika makala Sandbox (i.e. kuongeza "PageView = Shared&ToolPaneView = 2 "ya URL).
  3. Figure out your SharePoint _spUserId by following these crazy steps, amini au si:
    1. Kuingia katika SharePoint mazingira yako.
    2. Katika anuani ya shamba kivinjari cha, aina: "Javascript:tahadhari(_spUserId ").
    3. Kurekodi matokeo (ni "13" katika kesi yangu).

      image

  4. Kuongeza javascript zifuatazo CEWP yako katika mtazamo wa kanuni:

    <script
        "text/javascript"
        src ="../../jQuery Library/jquery-1.3.2.min.js">
    </script>
    
    <script aina ="text/javascript">
      $(kazi() {
    
        tahadhari(_spUserId);
    
        var theSecuredView = $('Iframe[FilterLink * = Secured% 20View]');
    
        kama ((theSecuredView.length > 0) && (_spUserId == 13))
          $('Iframe[FilterLink * = Secured% 20View]').mzazi().mzazi().mzazi().html("<tr Bgcolor = nyekundu><td>Hakuna mtazamo kwa wewe!</td></tr>");
      });
    
    </script>
    

Nimekuwa pamoja na kwamba tahadhari(_spUserId) mstari katika huko kuonyesha jinsi hii si kweli "kupata" maoni, but simply making it more difficult to see. More on that in a moment.

Kimsingi, jQuery is looking for an iFrame on the page who has an attribute that contains “Secured View” in its value. Once it finds it, we check to see if the current user is “13”. If it is, sisi kutembea hadi DOM kwa <TR> tag (ambayo mimi figured nje na kuangalia chanzo na hazieleweki ni) na kisha kuchukua nafasi ya kwamba tag TR na ujumbe wangu. Mimi kwa kweli hawajui jinsi hii ni imara (Mimi nina mashaka sana, kwa kweli), but it worked in my sandbox. If I find a better way, Mimi itabidi blog juu yake. Hii ni matokeo:

image

Mimi bonyeza kifungo OK na data ni kubadilishwa na ujumbe kubwa nyekundu:

image

Kama unaweza kuwaambia, the way I’ve implement this “security” solution is to allow the web part to render itself. After it finishes, Mimi overwrite maudhui yake kwa mtazamo wangu "Hapana kwa wewe!"Ujumbe.

Pamoja na ukweli kwamba siyo kweli "kuulinda '" mtazamo, ni muhimu na uwezekano wa baadhi ya kazi na wajanja, it may eventually be securable in a more formal sense. The fundamental issue is that the client is getting all the data and then, tu baada ya anapata data, it wipes it out. If the client is getting the data, mtumiaji wajanja wanaweza kuzuia jQuery kutoka mbio wakati wote na kuona nini yeye / yeye anataka kuona.

There are other drawbacks. This “security” approach is based off a _spUserId. We’d want to really secure based on the full SharePoint security model, or at least by user name. That becomes progressively harder, lakini mimi kuona baadhi ya mambo mema imeandikwa juu ya somo hili, hivyo mimi nina matumaini kuna jibu nzuri na tatizo kwamba.

orodha ya maoni wenyewe lazima yachujwe, kama inawezekana. I haven’t tried to figure that out. I assume it’s possible, lakini si kweli kutatua kimsingi suala la usalama kwa sababu mtu bado anaweza tu aina URL ya maoni wanataka (kama walijua ni). Hata hivyo, trimming makes sense. It’s a good usability feature and it helps to obfuscate things. If an end user doesn’t know that the view event exists, they probably won’t try to use it. Wakati mwingine, kwamba nzuri ya kutosha.

Kwa bahati, Mimi itabidi zaidi ya kuandika juu ya mada hii baada ya muda.

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Haraka na Easy: Njia Bora ya kutumia jQuery kwa Ficha Shamba Nakala ya kidato SharePoint

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

Hapo awali, I wrote about how to use jQuery to locate and hide a text field on a form. I didn’t care for the specific approach (Nilikuwa chaining wazazi - kwamba tu si kufanyika siku hizi, angalau katika familia ya ubora).

Wakati mimi kwanza kuanza kufikiri juu yake, Nilijua zinahitajika ili kupata <TR> ambayo mimi naweza kujificha waomba() njia. My early effort to find the correct <TR> ilikuwa kitu kama hii:

$('Tr:ina(pembejeo[title = Ficha Me!])');

tatizo na kwamba ni kwamba itakuwa kupata kila <TR> tag that had any parent relationship to the Hide Me! shamba, hata kama Ficha Me! ni Furushi ngazi nyingi kirefu katika <TR>’s. It turns out that on my sandbox form, kujieleza kwamba hupata 9 tofauti ya TR ambao Ficha Me! as a child somewhere in its DOM tree. I realized that I could walk back up the tree from the input field itself, hivyo kwamba ni jinsi gani mimi kuishia wazazi kutumia vibaya, lakini hawakuwa kukaa vizuri na mimi.

Mimi alitoa mawazo ya baadhi ya hii na moja ya mambo ya mimi kusoma hatimaye alifanya akili: Mimi naweza kutumia si() njia ya trim nje <TR>’s I don’t want in my wrapped set. Kwamba aliniongoza hii:

$('Tr:ina(pembejeo[title = Ficha Me!])').si('Tr:ina(tr)').kujificha();

kwanza kidogo anaona kila <TR> vitambulisho ambayo Ficha Me! field anywhere in their own hierarchy. It then strips out any <TR> kwamba pia mtoto <TR>. This leaves us with a single <TR> kwamba:

1) Hana <TR> mtoto kumbukumbu

2) Does have the input field as child.

Tunaweza kisha kuomba kujificha() njia ya kuweka kusababisha na sisi ni kosa.

Mimi bado kidogo neva kuhusu hili, lakini si kama neva kama wazazi chaining.

I don’t know if this is a best practice or not. There may be a more appropriate way of identifying just the <TR> that we care about in a SharePoint form. If you know, tafadhali post comment.

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Haraka na Easy: Kutumia jQuery kwa Ficha Shamba Nakala ya kidato SharePoint

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

UPDATE (tayari!): Sikuweza kufikiri ya njia bora ya Machapisho <TR> tag nataka kujificha na aliandika juu yake hapa. You may still find this article interesting anyway so I’m leavnig it up.

Nataka kuficha Nakala shambani, "Ficha Me!"Kama inavyoonekana:

image'

jQuery zifuatazo hana hila kwa ajili yangu:

<script aina ="text/javascript">

  $(kazi() {


    $('Pembejeo[title = Ficha Me!]').mzazi().mzazi().mzazi().kujificha();

  });

</script>

kanuni ni kusema, "Kupata mimi mashamba yote pembejeo ambao title = Ficha Me!. Kisha, kupata mzazi wake na kisha mzazi ijayo na * ijayo * mzazi (phew!) na waomba kujificha() njia juu ya jambo, chochote ni hutokea kwa kuwa.

I figured nje kwamba muundo mzazi na kuangalia HTML kwa fomu kuwa SharePoint umba kama inavyoonekana:

<TR>
    <TD nowrap="true" valign="top" upana="190px" darasani="ms-formlabel">
        <H3 darasani="ms-standardheader">
            <nobr>Kujificha Me!</nobr>
        </H3>
    </TD>

    <TD valign="top" darasani="ms-formbody" upana="400px">
        <!-- FieldName="Hide Me!"
                 FieldInternalName="Hide_x0020_Me_x0021_"
                 FieldType="SPFieldText"
        -->
        <span wewe="none">
            <pembejeo
                jina="ctl00$m$g_bdb23c2c_fde7_495f_8676_69714a308d8e$ctl00$ctl04$ctl02$ctl00$ctl00$ctl04$ctl00$ctl00$TextField"
                aina="text"
                maxlength="255"
                id="ctl00_m_g_bdb23c2c_fde7_495f_8676_69714a308d8e_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
                cheo="Hide Me!"
                darasani="ms-long" />
                <br>
        </span>


    </TD>
</TR>

Hii picha inaonyesha huo, lakini alama juu na wazazi:

image

mzazi wa kwanza (1) is a span tag. Span’s parent (2) ni tag TD na kisha hatimaye sisi kupata mzazi halisi nataka kujificha (3) ambayo ni tag TR yenyewe.

This is a pretty terrible approach I think because it’s extremely dependent on the very specific structure of this form. When SharePoint 2010 hutoka nje, this whole structure could change and break this approach. What I really want to do is craft a jQuery selector that is along the lines of “find me all the TR’s (na tu TR vitambulisho) kwamba kuwa mahali fulani katika watoto wao mambo ya shamba pembejeo ambao title = Ficha Me!". I starting from the bottom and moving up. Assuming I figure this out, Mimi itabidi baada updated "haraka na rahisi 'baada ya.

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Haraka na Easy: Kujenga jQuery yako mwenyewe Sandbox kwa SharePoint

Hii ni baada ya mwingine katika wangu inayoendelea mfululizo ya jinsi ya kutumia jQuery na SharePoint.
Kama unataka kujifunza zaidi kuhusu jQuery, Mimi sana kupendekeza: jQuery katika Action na kubeba Bibeault na Yehuda Katz.

Kupata ilianza na jQuery katika SharePoint ni ya kushangaza rahisi (kwangu). (I do have serious questions about a “best practices” approach to deploying these things to production, but that’s for another day). I’ve just started playing with this technology and to that end, I created a sandbox environment to use. If you’re looking to get started with jQuery, you may find this approach useful.

1. Create a Blank Site

Create a blank site somewhere in your site and call it something clever like “jQuery Sandbox”.

2. Download jQuery

You can download the jQuery javascript library from here: http://docs.jquery.com/Downloading_jQuery

Save that to to your desktop.

I have been using the “minified” version.

3. Create a SharePoint Document Library

In your sandbox site, create a document library.

4. Upload the jQuery Library to SharePoint

Access the doc library you just created and upload the jQuery library.

5. Create a Custom SharePoint List

I’ve started with a custom list because I want to muck about with standard SharePoint forms. You could also create a page in a pages library or web part pages and probably a lot of other places.

Add some columns to the custom list so that you have something to run jQuery against. My initial objectives were to:

  1. Hide a field.
  2. Assign a value to a field.

With that objective in mind, I added two text fields. Over time, I’ll be playing with links, images, lookups, nk.

6. Modify the NewForm.aspx Web Part Page and Add a Content Editor Web Part

This is a little black magic-ish , in that it’s a new concept to me. I first learned about this from Paulo Grenier, SharePoint jQuery Superstar, saa CodePlex yake tovuti ya mradi: http://spff.codeplex.com/.

Fuata hatua hizi ili kuongeza CEWP kwa ukurasa huo huo kwamba inaonyesha NewForm.aspx kwa orodha yoyote desturi:

  1. Kupata orodha ya desturi na bonyeza Mpya.
  2. Append zifuatazo URL: PageView = Shared&ToolPaneView = 2

Ambayo kubadilisha data yako boring vanilla kuingia fomu kutoka kwa kitu kama hiki:

image

Kwa hili:

image

Kuongeza mhariri maudhui ya mtandao sehemu ya ukurasa.

7. Kuandika jQuery wako kwanza Kanuni

Kufungua kwamba CEWP katika mtazamo wa kanuni na kuongeza yafuatayo:

image

Hapa ni kanuni halisi kama unataka nakala / kuweka:

<script
    "text/javascript"
    src ="../../jQuery Library/jquery-1.3.2.min.js">
</script>

<script aina ="text/javascript">
  $(kazi() {

    $('# ResultsID').html('Kuna' + $('A').ukubwa() + 'Vitambulisho vitambulisho kwenye ukurasa huu.');

  });
</script>

Kusababisha:
<div id ='ResultsID'></div>
/kusababisha

Note that the first <script> tag is referencing the actual jQuery library. Presumably, these things change over time, so you’ll want to make sure you a) use the right name and b) point it to the correct SharePoint document library.

Bask in the Glory

If you did it correctly, you’ll see a result similar to the following:

image

Wrapping Up

This isn’t the only way to get started, but it’s quick, easy and isolated from your existing SharePoint environment.

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin

Haraka na Easy: Kutumia jQuery ili Kuweka Thamani Shamba Nakala ya juu ya kidato SharePoint

I started playing around with jQuery yesterday. I’ve been wanting to do this for a long time, ever since Paulo Grenier started writing his series about jQuery for End Users at the venerable www.endusersharepoint.com web site. As I use it, I hope to add a series of “Quick and Easy” posts like this one. This post describes how to set a known text field’s value to anything you want.

In this scenario, I have created a custom list whose “new” form looks as shown:

image

This is the new form for a custom list with the default Title column and two list columns (not site columns; I don’t think it should make any difference).

The objective is to assign an arbitrary value to the field, “DefaultMeFieldNoSpaces” (you can tell I’m a bit of a coward with the “no spaces” thing going on, but I do spice it up at the end of this article).

This bit of jQuery worked for me:

<script aina ="text/javascript">

  $(kazi() {

    $('Pembejeo[title=DefaultMeFieldNoSpaces]').attr(
        {thamani: 'You are in a twisty maze of passages, all alike.'});

  });

</script>

As I understand it this bit of jQuery is saying, “find me any input tag whose title = DefaultMeFieldNoSpaces. Kisha, set all of their values to a famous phrase from an old computer game.”

Since there will only be one field on the form with a title equal to “DefaultMeFieldNoSpaces” we are assured of assigning a value to that field and no other.

What about a field whose name has spaces in it? It’s nearly the same:

<script aina ="text/javascript">

  $(kazi() {
     $('Pembejeo[title=Assign Field With Space]').attr(
        {thamani: 'You are in a twisty maze of passages, all alike.'});

  });

</script>

I think this is a fairly safe approach, meaning that we should be able to find the field that we want and only the field we want. If you look at the HTML SharePoint is giving us, it’s sort of messy:

<pembejeo
jina="ctl00$m$g_bdb23c2c_fde7_495f_8676_69714a308d8e$ctl00$ctl04$ctl02$ctl00$ctl00$ctl04$ctl00$ctl00$TextField"
aina="text"
maxlength="255"
id="ctl00_m_g_bdb23c2c_fde7_495f_8676_69714a308d8e_ctl00_ctl04_ctl02_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
cheo="DefaultMeFieldNoSpaces"
darasani="ms-long"
/>

“title” stands out as a recognizable and hopefully unique attribute to help us identify the specific column to which we want to assign our arbitrary value.

This is a foundational concept. Setting a field in an arbitrary way like this isn’t going to win any awards. Hata hivyo, if we want to do more interesting form level stuff (which all of us always want to do, bila shaka, right after we finish washing the dishes), like change the value of “field b” automatically based on the value of “field a”, sisi (Mimi) need to learn these things.

I think our best chance to get a real useful value here is via the title, at least for text fields. There may be a better, more reliable approach. If I find it, Mimi itabidi update hii post. If you know a better way, tafadhali acha maoni.</mwisho>

</mwisho>

Kujiunga na blog yangu.

Kufuata yangu juu ya Twitter kwa http://www.twitter.com/pagalvin